Synergy is a very useful piece of software for anybody wanting to share a mouse and keyboard between two networked computers.

Here is the setup I use to:

  • encrypt the key presses sent over the network from the synergy client to the server and
  • automatically restart the synergy client when it crashes.

First of all, I've got the following ~/.synergy.conf on both of my laptop and desktop machines:

section: screens  
section: links  
  right = mydesktop  
  left = mylaptop  
section: options  
keystroke(alt+shift+space) = switchInDirection(left)  
keystroke(alt+space) = switchInDirection(right)  

With this, I am ready to start the server on my desktop machine:

synergys -a localhost

Now, in order to encrypt the synergy client/server traffic, I create an ssh tunnel between the two machines:

ssh -f -N -L localhost:24800:localhost:24800 mydesktop

Then I start the synergy client on my laptop. However, some recent problems have convinced me to have a more robust alternative to simply starting the client like this:

synergyc localhost

As recommended by a few helpful people on #debian-devel, I decided to use the supervise tool (part of the daemontools package) to automatically restart the synergy client if it crashes. Here is how I do it:

supervise ~/.synergyc &

This command refers to a ~/.synergyc directory containing a single run script. That shell script consists of:

xset r rate 500 30  
/usr/bin/synergyc --no-daemon localhost

(The xset call is necessary since synergyc crashes seem to reset the repeat flag of X for some reason...)

The only problem I still need to fix in my setup is the potential password leak in the next few seconds after the synergy client crashes. Such a crash has already caused me to accidentally type my laptop password into a desktop IRC window the other day :(

Ideally, I would like the synergy server to swallow the first second or two of keyboard input after its client suddenly drops out. This could eliminate quite a few embarrassing wrong windows.

Why in the world would you have your password in a paste buffer?
Comment by Anonymous

My password was never in a paste buffer.

The problem I'm alluding to is that of starting to type my password into a regular password field on the synergy client (my laptop).

Then the synergyc client crashes before I'm done typing the password and so the keyboard comes back to the desktop where the IRC window is the one with the focus.

Because all of this happens within 1 second, I never noticed and quickly pressed Enter after finishing to type my password. That's why my password ended up in the wrong window.

Comment by Fran├žois
Ugh, does synergy crash a lot? Why do you use it instead of, say, x2x then?
Comment by Marius Gedminas

hm, i encountered a few problem with your solution.
1.: the --no-daemon enables the DEBUG-output.
2.: the client restarts itself in case there is no server available - which results in 100% cpu load

The solution:
/usr/bin/synergyc --no-daemon --debug FATAL --no-restart localhost

The restarting will be done by supervise or something like:
while [ true ]; do
sleep 1

Comment by Martin