Synergy has worked well for me over the last couple days, but setting up the connection (although not difficult) required a few steps that I’ve tried to streamline.
The following setup is based on a synergy configuration similar to the following.:
section: screens
desktop:
laptop:
end
section: links
desktop:
right = laptop
laptop:
left = desktop
end
BTW, desktop and laptop are arbitrary names I’ve selected for clarity.
Automatically start the synergy server after logging in to gnome on the “desktop” computer to which the mouse/keyboard is physically connected as follows:
- Go to Main Menu -> System -> Preferences -> Sessions
- Under Startup Programs click Add
- In the Edit Startup Program dialog enter the following command to start the synergy server: synergys -n desktop
Since synergy traffic is plaintext, I forward the communication through ssh from my laptop as described in the Synergy documentation. I also use ssh to communicate with my desktop computer for other purposes, so I use public key authentication to avoid having to type my remote password every time I try to connect. Since I use a passphrase, however, I have to add my key to the ssh agent with a call to ssh-add. This requires me to enter my passphrase…but once added I can connect to the desktop machine without a passphrase for the duration of my session. For more info, check out the Ubuntu SSHHowTo documentation. Since I tend to forget to add the key, I decided to run ssh-add when I log into gnome on my laptop (”laptop” above) as follows:
- Go to Main Menu -> System -> Preferences -> Sessions
- Under Startup Programs click Add
- In the Edit Startup Program dialog enter the following to add your key to the authentication agent: ssh-add
In order to establish the synergy client connection, I wrote the following script:
#!/bin/bash
#
# Script to securely connect to synergy
# server on desktop machine for sharing
# keyboard and mouse
#
# IP address of desktop machine
DT_IP="xxx.xxx.xxx.xxx"
# Setup port forwarding
ssh -o ExitOnForwardFailure=true -f -N -L 24800:$DT_IP:24800 $DT_IP
# Start synergy client
killall 'synergyc'
synergyc -1 -n laptop localhost
This script establishes the port forwarding through ssh and then starts the synergy client. Instead of calling the script from the command line, I added a custom application launcher to a panel in order to start the connection with a simple mouse (touchpad) click. There are a few things to note:
- The ssh connection doesn’t require a passphrase here since I added the key to the authorization agent using ssh-add at gnome startup
- The
ExitOnForwardFailureoption is used so that the process will exit if the connection fails. If, for any reason, the synergy client connection is closed, the ssh forwarding will still remain active. This script can be rerun without any worry of multiple (failed) ssh forwarding attempts. - The
-1option is used in the synergy client so that it won’t try to restart if the connection fails for any reason. Without this option, the client will continuously attempt to reconnect, consuming system resources.
So now, when I log into gnome on the desktop computer the synergy server automatically starts. When I log into gnome on the laptop machine I am prompted for my ssh passphrase. All I need to do to start a secure synergy connection from my laptop to my desktop is click on my custom application launcher.


