How to enable secure and convenient key-based SSH authentication (the easy and automagic way)

Recently I was up to the task of improving the SSH security on multiple servers. I was going to replace the less secure password based authentication with the more secure method of using SSH keys, which also has the added benefit of being more convenient as I do not have to type my password each time I login to the servers.

And being a really big fan of automation, and especially to avoid reproducing boring and repetitive tasks, I thought I might find and smarter and easier way than remembering all those steps needed for each machine. So I decided to write an automagic AllowSSH bash script for this. This way I could perform the task easily and more reliably on multiple hosts (and it will be far easier to remember in the future). This is how the script is used:

$ ./AllowSSH root@192.168.100.100

Before running the script you need to make sure you have a SSH RSA key generated and that you are logged in as the user you want to grant access to the remote machine. Se details below with an description of what the script actually does.

The easiest way to install the AllowSSH-script to your local computer is running the following command:

$ curl -L http://bit.ly/install-allowssh | bash

Read More

Install Visual Studio for Mac preview (the easy way)

If you are interested in evaluating the new Visual Studio for Mac (Preview) from Microsoft, the easiest way to install Visual Studio on your Mac is to simply open up a terminal window and execute the following command:

$ curl -s https://git.io/mikaelleven-vsformacprev | sh

This will download the disk image, execute the installer and remove the disk image when the installation has finished.

If you want to preview the script before executing it (which I strongly encourage) navigate to the url https://git.io/mikaelleven-vsformacprev or choose to Read more below.

Read More

Great Way To Visualize and Communicate A/B testing, and to Make Good Use of “Big Data”

Pendlingskollen_Visualizing_A-B-Test_Using-BigData_MIkaelLeven

Visualization of A/B testing. Old traffic control system to the left, actual arrival time in the middle and the new predictive algorithm to the right. Currently the new algorithm has a distinct advantage with a score of 23,010 vs. 1,504 for the old system.

This is a great example that shows how we can benefit from “big data” to achieve a greater good, wether the information comes from historical data, is fed live through M2M sensors (machine-to-machine/Internet of Things) or a combination of the two.

In this example, StockholmsTåg use quite insipid information (at least when looking at it as isolated data) – the weight of a railway car – to make insightful predictions when there is a disturbance in the railway traffic. This is possible thanks to placing the insipid data into a broader perspective where the data comes to life and becomes meaningful. This way they are able to determine which railway wagons that contains the greatest number of people, so when there is obstacles on the tracks they can predict how this will effect the traffic in general and accordingly prioritize those wagons with most people, and by doing so they minimize the overall social effect of the inevitable (the obstacles itself is hard to avoid).

Pendlingskollen_Visualizing_A-B-Test_Scoring_MIkaelLeven

A/B test scoring. In this sample the new system has gained one point, illustrated by the green area.

And what is particularly interesting in this case is how they visualize their A/B testing, by giving the old and the new system a score based in their performance, and how they communicate this transparently directly to their end-users (the commuters).

StockholmsTåg has empowered their data to better be able to predict the effects of upcoming disturbances in the railway traffic, and they also found a great way of visualizing this. In the long run it also means they can have a more proactive approach towards their customers regarding disturbances and the potential workarounds, and thanks to this greater detail the commuters can make more well-founded decisions to make the most out of their time.

http://pendelprognos.technology/

What is this (hot topic) ‘Internet of Things’?

InternetOfThingsAlmost every day topics such as Internet of Things, wearables, smart watches and home automation is mentioned in media and other sources. At least on remotely tech-oriented sources. Also mentioned in these contexts is considerations (or rather concerns) about security and privacy. These topics is close to my heart and I wanted to give my point of view on some of them, while also giving a brief introduction into the (mysterious?) area Internet of Things for those not really sure what this is. Kind of giving you a quick-start guide to encourage further reading. This post turns to both those without prior knowledge but with an general interest to learn what IoT is, as well as those already familiar with the topic who are ready to get started hands-on with IoT but want learn before they start. The intention is to follow up this general post with more detailed post digging into the technologies and how to get started when you actually begin building the first Internet of (Your) Things.

So what is this “Internet of Things”?

It is really hard to accurately define what Internet of Things (IoT) is using one short description. In general IoT is a concept where “anything” is connected to the Internet, or rather “anything connected to anything” (which is more true to the basic idea of IoT). We could called this “network of everything”. From my point of view, the best way to understand what IoT is actually is to talk about what it could be used for. The greater mening of the concept.

Automation (“smart homes” and industry automation) have actually been around for quite a long time. Historically (home) automation has been about enthusiasts creating nifty solutions for their private homes, mostly because it is fun but also to make their lives somewhat easier. It could be wirelessly controlled lightbulbs or automatic plant watering systems. Likewise the manufacturing industry has a lot of automation and monitoring going on. And aerospace research is also very much about automation and monitoring. One thing in common, from a historic point of view, is that these technologies where costly, inaccessible and often required some expert skills in electronics. And not to mention by far not as powerful as they are today.

The last decade this has truly changed. Today there is a lot of different, and cheap, solutions available to consumers. We have access to a extensive set of of-the-shelf consumer-friendly products to create smart homes. Additionally we have access to great amounts of processing power. All these devices getting cheaper, smaller and more energy efficient. And it is here we are getting closer to the true Internet of Things.

Basically IoT is about connected devices and sensors. Not necessarily internet-connected, but at least, connected devices. They could be connected to some local gateway/hub at your home gathering all data from these sensors or they could be connected to the Internet and the cloud. The benefit of IoT is when you have multiple devices connected to a common place where this data is aggregated and can be used to add new areas of use or to increase smartness of existing functionality. A temperature sensor is still just a mere temperature sensor until you pair it with one or more additional devices that can act on the sensor information to achieve new additional and/or smarter functionality (think of it as 1+1=3).

Internet of Things Simplified ArchitectureLet’s get a bit more technical

We could, generally speaking, look at IoT architecture using this simplified model with four layers/tiers*.

  1. Sensors and devices (collects data)
    This is where all information (data) is originated and created/obtained
  2. Hubs/gateways (proxies/sends data)
    In the web of interconnected devices, hubs is responsible for gather data from (possibly) multiple devices/sensors and distribute them throughout the network. Typically this layer is when data goes from being on-premise (local) and leave to the Internet/cloud (global).
  3. IoT software platforms/frameworks (stores and analyzes data)
    This is the very core of the IoT architecture where all data from all sensors and devices, via hubs/gateways, are gathered and stored. Typically this is the place where data being analyzed and some event could be triggered.
  4. End-user applications (visualizes and reacts on data)
    The fourth layer is where data actually becomes useful. I.e. this is when data either being presented/visualized or when data triggered an event that actually leads to something actually happens (a change of state of any kind).

* Each of these tiers could actually be combined into one and the same product/solution. It would be absolutely possible, and viable, to combine multiple sensors and one hub into one physical product. Or to combine tier 3 & 4 to create a service that both stores, analyzes and visualizes the data. Or in a particular situation you might want to have a local micro IoT at home where you have combined at least tiers 2 through 4 into one product and only have detached sensors. And all of this is only a simplified model with some examples as there is no definite rule exactly what IoT is and how is to be used.

Neither of these layer/tiers is technology or manufacturer specific. However between each tier there is a need for a common language or a contract for information exchange. It would be possible for a hub to use one language to receive data from sensors and another language to send data to a IoT framework. But the sensor cannot use different languages.

This general concept would work equally well with proprietary protocols and products as well as with open source products and standardized protocols. And it would work through Internet, a typical local computer network or any non-standardized “private network”. Both wired and wirelessly. Internet of Things is not a technique but rather a concept.

The BFF of IoT

IoT also have a best friend, or sibling, which is one key part when we move from simple automation to something really smart. Using “big data” – i.e. lots of processing power with access to huge amounts of data – we can make truly smart technology using predictions and analyzing of behavior patterns. Without “big data” IoT would be nothing more than a lot of connected devices without any greater meaning. Like a thousand people standing still in the same place, no one interacting with one another. That is lots of people, but quite meaningless as they don’t do anything. Compare this with these 1,000 people actually interacting with each other, exchanging experiences and together forming patterns. Think of this combined source of knowledge with one thousand brains in one place communicating with one another. This is IoT + “big data” – when this “network of everything” comes to life and becomes meaningful.

What is I(o)T good for and why should you and I use it?

A common (mis)perception of IoT is that every home appliance and device should be connected to the internet. However, IoT is not really about 50 million internet-connected fridges, but rather about connected sensors and devices where it makes sense. Sure, it would be cool if the fridge could order some milk when the milk is almost depleted. It’s arguable if that’s really practical. Maybe you want to wait just a little bit to order more stuff, or possibly you are about to go on vacation (and then you wouldn’t want milk in the fridge getting old).

Looking at a more practical approach to the fridge scenario could be: each package of milk could have a smart label armed with a sensor monitoring the state of the milk and a short range wireless communication unit (RFID/NFC). When the milk is nearing it’s end date the sensor sends a wireless signal to the fridge, which in turn could display a alert on the fridge’s display (or, by all means, it could also send a tweet or alert of some kind to your phone as well). Additionally your “remember the milk”-app (grocery shopping list) on your phone could have “one package of milk” listed as a suggested purchase. This could be both a viable and practical example scenario where IoT could enrich or simplify our lives.

To give a better idea on the multitude of scenarios where IoT in one way or another could be used I have collected some examples below. This is by no means a exhaustive list of all the possible scenarios. We should also expect many new ways to utilize the IoT concept that we cannot think of (or imagine) today. Much like we couldn’t predict what impact smartphones would have and how we would actually use them today.

  • Green tech – Smart technology to predict behavioral patterns to save energy consumption and use resources smarter. For example if we have smart heating systems that will report to energy suppliers about upcoming expected usage levels, time and
  • Home automation – Devices that make our traditionally “dumb” houses, smart. Mostly a matter of comfort.
  • Safety – Using various devices interconnected we could for example rest assured our kids have come home safely from school (and follow their way home). With connected locks the house could automatically get unlocked without the need to hand out physical keys to our kids or require the to remember pin codes.
  • Surveillance – Internet connected surveillance system monitoring your home, office or a public place like the subway.
  • Predict (global) health trends – Using wearables and behavioral patterns, maybe the combination of drugs for a particular illness sold, could give us quick indication of early stage epidemics
  • Optimized transportation – See patterns in how humans (or drones) travel and optimize the route accordingly
  • Proximity based interaction – based on your location and proximity relative to other things, this could be used as means of interaction and identification (or why not authorization of payments?)
  • Personal health monitoring – Map activity patterns and personal health status

There is also some examples of typical places where these devices and sensors could be used:

  • At home
  • In a vehicle
  • In an industry
  • On, or in, your body – aka “wearables”

A real world (hypothetical) scenario

To further clarify the benefit of IoT we could consider a more concrete scenario. Let’s begin with you, your home and a simple heat source (really doesn’t matter which type, but let us assume it is a electric radiator used to warm your house).

In the first stage, pre-IoT, your heater is simply on or off. When you set it to “on” it simply uses 100% of it’s maximum energi usage, regardless of how warm or cold your room actually is, and you have to manually control it.

Let us now take this to stage 2, the first step to a smart home. We add a temperature sensor with the ability to control your radiator – On or Off. This is what typically is called a thermostat. Now we have a basic micro IoT network with two (or actually three) devices. One input device (the sensor – thermometer), a hub (the thermostat with controller logic) and the output device (the heat radiator). With this basic setup we have somewhat intelligent heating that keeps our room heated without excessive usage of resources (electricity). However it is not really smart yet.

In the next stage, where we moving towards a more true IoT solution, we also add your telephones GPS to the mix. If the GPS tells that you are far from home the thermostat will lower the temperature with 2°C. And when the GPS reports you are getting closer than 2.5 miles from home it will begin heating back 2°C. Thanks to this smart approach you always have a perfectly tempered home, while at the same time have lowered your overall energy consumption (since there is no need to heat the room when you are not there). Already with as little as two sensors (GPS + thermometer) and one output device (heat radiator) connected to an IoT hub you have achieved a smart home with a smaller electricity bill.

We could of course stop there and be satisified. However let us also add another house to the mix, 5 miles from your home. This house also has an IoT gateway as well as an outdoor temperature sensor. Using the data from this house, with triggers on increasing/decreasing outdoor temperatures, we could predict the needs for heating at our house. So when the temperature drops at the other house we could begin increasing the heating in our house, and as our house hasn’t already being cooled down due to the lower outdoor temperature, we could run the radiator at a lower level which consumes less energi (i.e. more energy efficient). Another benefit is that we would attain a more stable indoor temperature as we can begin the heating before the temperature drops outside and thus avoid larger variations. Now we have a truly smart home which is even more energy efficient and also more comfortable.

At this stage we have achieved benefits mostly from a personal perspective, we have yet to achieve any greater benefit on a larger scale. Sure, our lowered electricity bill does contribute to an globally decreased need for energy which is environmentally good. Should we add another party to this mix – the power companies – we could attain even greater effects. Let’s consider if our, now smart home, also could communicate with the systems of power companies and let them know how our heating equipment currently operates, and also which changes our system has predicted. For example if our house is running at max levels and our neighbors house needs heating, the power company could tell our neighbors’ system to wait for a short while before starting. This is possible thanks to our house has reported that the desired heat level soon is achieved. Such intelligent system achieves two important things for power companies. First, their maximum energy supply level could be lower, secondly they can predict when they actually will need the power and thus minimizes the need to have overcapacity to manage unexpected peaks. The exact same pattern is equally applicable for washing machines, dishwashers etc. Looking at this at a grand global scale this could have a significant impact on global energy consumption and by extension the environment. And this is one reasons why IoT is so promising and interesting.

Security and privacy considerations

Wether you are a business creating your own products (alternatively an independent maker) or a consumer, you need to factor in aspects like security and privacy. Below I will shortly describe what I think these two aspects mean in the context of Internet of (My) Things.

Security

The security part is primarily about technical, digital and physical control of access. Every step of the chain must be as secure as possible. There will surely be a tradeoff between convenience and security and here you need to value how much convenience you are prepared to let go in favor of security. Or how much security you are willing to offer to gain convenience. From a consumer point of view this would probably be in the are of how you connect sensors/devices to the other parts of the system. And from a business side of things this would surely be related to how mature your audience is and thus how complexity they can cope with when handling your products. In either case security is paramount, both for individuals but to the market in general (should IoT and cloud based solutions be considered unsafe and unreliable the market will surely notice a significant setback). Security first, convenience second.

Privacy

In contrast to security, integrity isn’t that much about physical or technical limitations, but rather about how your information could be accessed and (mis)used. From a business point of view this is very much about anonymizing data before making it publicly available and to have a clear policy about storage and handling of end-users data. Looking at it from a consumer perspective this is mostly about choosing between lokal solutions (where you have full control) or opting for a cloud based solution. In the latter case the comnsideraton would be to choose a supplier who you trust and you find to have a authentic data integrity policy. And one last word of caution: without security there is no integrity. The first step is to secure the data and communication.

IMG-CAPA-IOTConclusion

What IoT really is about: gather lots of (sensor) data, process and analyze these large quantities of data, make predictions and finally make good things using these insights. Especially when we monitor and analyze data over sustained periods of times we can draw conclusions on behavior and be really smart and predictive when taking action.

Hope this gave you an basic idea what IoT is and the purpose/benefit of it. And please let me know what you think. Maybe there is something missing in this overview. Or it might be some part that needs further clarification. In any case I would appreciate the feedback.

Explanation of terms

Some new words, but what do they mean?

  • Internet of Things – A network of devices/sensors connected to each other
  • Big data – Large amounts of processing power analyzing biq quantities of data, and more importantly, the ability to do this i real time to instantly trigger an reaction based on the analysis.
  • Hub/gateway (in this context) – A sort of computer resposnible for send information between sensors and the IoT software/frameworks. This could also be called a proxy or a “middle man”.
  • Sensor – A (typically) small device with some sort of measuring/probing capabilities
  • Device (in this context) – Any form of electrical device that might be connected to the IoT network to supply the network with data (such as smartphones, wearables or computers in general). The difference to sensors is that these devices does not really measure anything, but rather supply data in other ways.
  • Wearables – small devices placed at, or within near proximity of, your body. Apple Watch for example.

Next step: hands-on with IoT technology

Keep an eye out for the next post in this series if you are interested in getting your hands dirty with IoT technology yourself.

What makes a good leader?

Richard-Branson_What-makes-a-good-leaderLeadership is a skill hard to master. And a skill that might, or might not, come naturally to you. Regardless if you are born with the ability to lead or it is something you have learned, it is an area of expertise where you can never be fully taught. You need to constantly challenge yourself, be open minded to new ways to tackle challenges and last, but not least, be curious about the views, ideas and thoughts from the people you lead. And for me this is about constantly challenging myself in a strive to continuously improve my skills as a leader. Also, I listen and learn from others successes (or failures) and use this insight to raise the bar for myself.

At the end of the day, leadership is about people. Being a good leader is mostly about enabling others to do great things. Not that much about you really. And for me, leadership is not about managing people, but rather inspiring people. To encourage them and challenge them to raise their bar.

If you are manager, or aiming for a leadership role, I encourage you to read this insightful blog post by Mattis Erngren: Dungeon Master Leadership – The Story of How D&D Made Me A Better Boss. Then you could follow up and read (learn) more from great leaders such as Richard Branson, Steve Jobs and James Caan. Despite their (quite) different ways to lead people, one thing in common is that they have all made a great impact on their respective business culture and the people around them. To start with you could read about Richard Branson’s Three Most Important Leadership Principles.

Two web browser buttons I miss

WebBrowser Buttons I MissToday web browsers has standardized behavior for navigating back and forward as well as stop loading respectively re-load a page. But there is two buttons I (personally) miss:

Scroll top top
On my iOS device I can touch the menu bar at the top of any application to get to the top (where menus etc most often are). Many websites solves this using various home made solutions, most of them not really that good, but worse it they never behave the same. This could easily be solved by the web browser manufacturer by adding a toolbar button (and keyboard shortcut) for this. Regardless of where you are on the page, regardless of website, you could always scroll to the top.

Show menu
The second button might be a bit trickier to solve using contemporary standards and browser compliance. However almost every website has a main navigation of some sort. Most websites also has a sitemap. Both the sitemap and the typical navigation contains structured information that describes the structure of a website. Using this data it would be possible for the browser to present a standardized menu regardless of which page you are looking and no matter where on the page you are currently viewing. And if this is hard to achieve, the browser would at least be able to display the implemented html menu (by simply open it and scroll into focus). Either way on long pages and especially those websites with the mobile friendly “hamburger menu” would benefit of this button.

 

Guide: Mastering your Apple keyboard on Windows

AppleKeyboardWinWhether you just prefer using the Apple keyboard with your Windows computer, or you are running a Windows virtual machine guest on your Apple hardware, this guide will help get the most out of your experience.

Please note: these tips is based on my experience with a Swedish keyboard layout, and this might differ depending on your actual layout.

Make your keyboard work as it normally does

Once you have installed you keyboard and all basic functionality is in place (i.e. you can log in, write text etc) I recommend the convinient tool Apple Wireless Keyboard (AWK) from UX Soft. This utility program will fix most of your function keys to behave like they normally do on your native Mac OS X experience. You can easily switch between Special/Media Keys mode (Brightness, Media Playback, Volume etc) or Function Keys mode (F1-F12).

Improve your effectiveness by using your keyboard as you’re used to

Although AWK fixes the basic special key functionality for your Apple keyboard in Windows there is one area that (previously) caused me a lot of headache. And that is all the Cmd + XXX combinations you are used to. Take “Copy” for example. On your Mac OS X machine you would use Cmd + C to copy some text, while logged into Windows you have to use Ctrl + C instead. And if you are like me and rely heavily on keyboard shortcuts to be effective and also switch back and forth between OS X and Windows this becomes annoying and a real productivity killer.

So I’ve put together a small utility (actually a compiled AutoHotKey script) to fix a lot of these shortcuts. Below you will find some examples, for full details refer to the Apple Keyboard for Windows (AKfoW) project page.

Basic features of AKfoW:

  • Now Media Playback works with other programs than iTunes, like Spotify for example
  • You can now use Cmd + T to open tabs and Cmd + W/Q to close windows and entire applications (the latter is equivalent to Alt + F4)
  • Copy, Cut and Paste works as you are used to
  • Cmd + Arrow works like Home / End / Page Up / Page Down
  • Cmd & Shift & Alt + Arrow will snap the current window to Left / Top / Right / Bottom (like Docker etc works on OS X)
  • F13 can be used to take screenshots
  • Also there is a “developers special”: Alt + 8/9 will get you square brackets and adding the Alt-key modifier will give you curly brackets instead

Unfortunately I haven’t found a solid replacement for Alt + Tab (which still causing some frustration for me).

Reclaim disk space from your Virtual Machine

After running your virtual machine for some time you probably have created, deleted and modified a great deal of files. And let’s not forget the operating system which constantly modifies files. This will take up space on your host operating system, even if these files should be deleted.

Some virtualization softwares do support reclaiming disk space out-of-the-box. VM Ware Fusion for Mac is one example of such software. And most of the enterprise solutions also support this. However, should you be using other tools that do not have this option, such as VirtualBox, there is still some ways to achieve this.

Continue to read more about how free space is managed in virtual machine guest os:es or skip directly to the solution.

Read More