Synergy, Security, and Tips
This article introduces how to set up synergy, a tool which lets you easily share your mouse and keyboard for multiple computers.
Introduction
More displays mean better productivity to me. Currently, I’m using five — two for emacs, one for terminal, one for email, one for web search — and I find them very useful.
Ideally, you may have a computer and a special hardware such as KVM switches or Matrox TripleHead2Go which connects multiple monitors to a single machine. However, they are pretty expensive and not an option for a poor graduate student like me.
The alternative is to have multiple machines, each connected to one or two displays. Then, you can use synergy to control them with a single mouse/keyboard. In my case, I have two desktops and one laptop. With shared clipboard feature, you have an illusion of having a single machine with multiple displays.
Basic Setup
In this article, I explain the set up based on my configuration. I have Macbook Air, iMac, and a Linux machine. We will install synergy server on the Linux machine and two clients on Macbook Air and iMac.
Linux (server)
- Download and install synergy from the webpage.
- I’m using version 1.4.12, protocol version 1.4
- Save the following file as
~/.synergy.conf
. You may need to editscreens
andlinks
section. You also need to provide an IP address of each machine inaliases
section.
# +--------+ +--------+ +-------+
# | Mac Air| | Linux | | iMac |
# +--------+ +--------+ +-------+
section: screens
Linux:
halfDuplexCapsLock = false
halfDuplexNumLock = false
halfDuplexScrollLock = false
xtestIsXineramaUnaware = false
switchCorners = none
switchCornerSize = 0
iMac:
halfDuplexCapsLock = false
halfDuplexNumLock = false
halfDuplexScrollLock = false
xtestIsXineramaUnaware = false
switchCorners = none
switchCornerSize = 0
MacAir:
halfDuplexCapsLock = false
halfDuplexNumLock = false
halfDuplexScrollLock = false
xtestIsXineramaUnaware = false
switchCorners = none
switchCornerSize = 0
end
section: links
Linux:
right = iMac
left = MacAir
iMac:
left = Linux
MacAir:
right = Linux
end
section: options
relativeMouseMoves = false
screenSaverSync = true
win32KeepForeground = false
switchCorners = none
switchCornerSize = 0
end
section: aliases
Linux:
<IP of Linux>
iMac:
<IP of iMac>
MacAir:
<IP of MacAir>
end
- You can start synergy daemon by typing
synergys --daemon --name Linux -c ~/.synergy.conf
Mac (client)
I found problems using the client that I get from http://synergy-foss.org. It seems Quicksynergy works on my Mac machines. You can start the client by typing
/Applications/QuickSynergy.app/Contents/Resources/synergyc \
--name <CLIENT_NAME> localhost
In my configuration, <CLIENT_NAME>
is either iMac
or MacAir
.
Security Issue
The above setup has a security issue. Whatever you type will be sent from the server (Linux) to the other machines (iMac/MacAir) as a plain text. It means that any computer in the same network can see what you type including passwords. This could be problem if you are on a school/company network.
Synergy recently started to provide encryption methods. However, there is a recent article discussing the problem of the current encryption methods and possible attacks on them.
However, we can still rely on SSH tunneling. Simply put, we create a secure channel of communication between a server and clients. Then, let synergy use the channel to exchange information.
In server (linux), we start synergy daemon with --address :24800
option to specify the port number which we use as a tunnel.
/usr/bin/synergys --daemon --name Linux -c ~/.synergy.conf --address :24800
In client, we first establish the SSH tunnel and run synergy client:
ssh -f -N -L localhost:24800:<SERVER-HOSTNAME>:24800 <SERVER-HOSTNAME>
/Applications/QuickSynergy.app/Contents/Resources/synergyc \
--name <CLIENT_NAME> localhost
Here <SERVER-HOSTNAME>
is either IP address or domain name of the server.
Tip: Keyboard Shortcut to Navigate Screens
Having multiple monitors create a new problem. It takes some time to
move the mouse pointer from one side to the other side (in my case,
it’s about 5400px to cross). Fortunately, synergy provides a solution
for this problem. You can add the following to the ~/.synergy.conf
file on the server.
section: options
keystroke(shift+alt+left) = switchInDirection(left)
keystroke(shift+alt+right) = switchInDirection(right)
end
Now you can press shift+alt+left/right
to move the focus to the
left and right.
Tip: Wakeup Script
There is a possible problem when the computers go to the sleep mode. You can wake up the computer which has a mouse and keyboard connected. However, there are no ways to wake up the other machines. In my case, they are Mac machines and I found the following “wakeup” script from the web.
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>
#include <iostream>
void set_request_idle(bool request)
{
io_registry_entry_t entry = IORegistryEntryFromPath(kIOMasterPortDefault,
"IOService:/IOResources/IODisplayWrangler");
if (entry == MACH_PORT_NULL) {
return;
}
IORegistryEntrySetCFProperty(entry, CFSTR("IORequestIdle"),
request ? kCFBooleanTrue : kCFBooleanFalse);
IOObjectRelease(entry);
}
int main(int argc, const char **argv)
{
const std::string &command = (argc > 1) ? argv[1] : "";
if (command == "idle") {
set_request_idle(true);
} else if (command == "wake") {
set_request_idle(false);
} else {
std::cerr << "usage: " << argv[0] << " (idle|wake)\n";
return 1;
}
return 0;
}
You can save the file as wakeup.cc
and compile it on Mac as follows.
clang++ -Wall -O3 -framework Foundation -framework IOKit wakeup.cc \
-o ~/bin/wakeup
Then you can ssh from the server to a client and remotely execute the wakeup script as follows:
(SERVER) $ ssh <CLIENT_IP> "~/bin/wakeup wake"