When working with multiple computers it can be a pain to have to interface with multiple inputs such as keyboards, mice, etc. Not only does it get confusing from time to time, but it’s just plain annoying. Especially when there is a laptop in play.

In my case, I wanted to use my mac laptop (lid closed) and an external display, since staring down at a 13” screen for 8+ hours a day wasn’t going over too well with my neck. The way to go about doing this is to close the lid, plug in another input device and monitor and start typing or clicking on it and unlocking the screen. With the mac laptops this is also only possible when the AC power adapter is connect. Due to some networking issues at work I was also required to plug in to a wired network as well. So now I had to plug in: power, mouse, keyboard, monitor, and a network cable. This worked well for me for about 2–3 days. Then I realized something. Plugging all of this junk into the the laptop every day when I get into the office and unplugging it when I leave was a pain in the ass. That’s when I remembered about an old friend of mine called synergy.

synergy

Synergy is a software package that attempts to emulate a KVM switch, minus the video portion—since it’s software. It works by running a client/server desktop application. One computer acts as the server, sharing its mouse and keyboard, while the other computer connects to it as a client to borrow the shared input devices.

I’m not going to get into the basics of configuring synergy from the ground up (after all, I did say it was an old friend, right?). The point I wanted to focus on in this post was how I took it a step further by adding encryption.

I was a little bit concerned about security this time around, since previously when I used synergy at work I was connecting a linux computer (host) to a windows box (client) and I didn’t really care about security on windows because—well—it’s windows. Now I am using synergy to connect the peripherals which are attached to the same linux machine to a mac laptop. Mac OS X—like linux—requires authentication every now and then, and my login password isn’t something I wanted to broadcast over the office network in broad daylight. After doing a bit of research I found out that I can tunnel the synergy client via SSH to encrypt it. After following the instructions and doing some tests I created a couple of scripts to do this for me:

synergy-connect

The first script is called synergy-connect. It creates the SSH tunnel on my localhost and it forwards all requests on port 24800 (the default synergy port) to the same port on a different host name.

Remember that when configuring synergy, synergy requires a host name to be used. Synergy will not connect to an IP address. This means that if you are having trouble connecting your synergy to an IP address it’s time to add some entries to your hosts file and optionally set up a static IPs for the machines as well.

synergy-connect:

#!/bin/bash

ssh -f -N -L localhost:24800:remoteHostName:24800 remoteHostName
synergyc localhost

resyn

resyn is another script that I created which closes out synergy and reconnects it, this is extremely convenient for when you need to reconnect and doing so means losing your only input device to type in the connect command again after disconnecting it.

resyn:

#!/bin/bash

killall -9 ssh
killall -9 synergyc
synergy-connect

blog comments powered by Disqus

Published

23 January 2012

Tags