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:
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:
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:
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.