How to Configure Synergy on Linux to Share Keyboard and Mouse with Multiple Systems

by Sanjay Kumar on March 19, 2014

Synergy is an open source network utility which can be used to share one keyboard and mouse with multiple systems.

Synergy utility works on client-server model.

The system whose keyboard and mouse you want to share, runs the synergy server service (synergys), and all the other systems runs the synergy client service (synergyc) to connect to server.

Synergy is a platform independent utility. Compiled version of synergy is available for various platforms including Windows, Linux, Mac OS X, Android and Apple iOS. You can download source code and compiled version from here.

Use the appropriate package management command to install Synergy on your system as shown below. For Windows, you can directly download executable and install it.

# For Mac OSX :
sudo port install synergy

# For Fedora, CentOs and RHEL :
sudo yum install synergy

# For Ubuntu, LinuxMint and Debian :
sudo apt-get install synergy

Example Synergy Configuration Setup

In my case, I have three systems mac-dev (OSX Maverick 10.9.1), nix-dev (Ubuntu), fed-dev (Fedora 20) which is connected in local network.

Synergy Keyboard Mouse

After installation, you need to define a configuration file to run synergy.

Configuration file has information about how these systems are connected in X,Y Plane. The synergy configuration file has the following sections:

  1. screens
  2. links
  3. aliases
  4. options

The default syntax of all sections is shown below. Just replace the name to one of the above section name.

section: name
arguments
end

Screens Section

Screens section will specify how many systems are going to connect through synergy service.

In screens section, either you can use either ip address or hostname of the systems.

Following is my configuration file for screens section. Here I’ve used two hostname and one ip-address (for fed-dev system).

section: screens
10.112.10.27:
nix-dev:
mac-dev:
end

Links Section

Links section will specify how these systems are going to connect in X,Y Plane.

There are four options such as left, right, down and up to connect screens to each other. Before writing link section, keep the system on which you want to run synergy server service ( it means you want to use keyboard and mouse of the system in all systems which are connected across local network.

In my setup, I want to use nix-dev systems keyboard and mouse in mac-dev, and fed-dev. So, I kept nix-dev in center and mac-dev of left of nix-dev and fed-dev is right of the nix-dev. In links section, you can write any screen first or last, it doesn’t matter.

section: links
nix-dev:
left = mac-dev
right = 10.112.10.27
mac-dev:
right = nix-dev
10.112.10.27:
left=nix-dev
end

Aliases Section

In aliases section, you could write alias for domain name to use short name in screens and links sections.

section: aliases
nix-dev:
nix-dev.thegeekstuff.com
mac-dev:
mac-dev.thegeekstuff.com
end

Options Section

In options section, there are list of arguments which can be use to modify uses of synergy service in configuration. You can get full list of options from synergy website.

section: options
keystroke(alt+left) = switchInDirection(left)
end

Start Synergy Service

For minimum configuration, you need atleast two options such as screens and links.

In the system which has keyboard and mouse, you need to start synergy server service as shown below, which will wait for all client to connect according to configuration file.

synergys -f -c mysynergy.conf

-f flags : To run synergy server service in foreground, by default it runs in the background
-c flags : to pass configuration file to synergy server service

For other connected systems, start synergy client service with server hostname or server ip address on which synergy server service is running as shown below.

synergyc -f nix-dev

or

synergyc -f 10.112.10.26

-f flags : to run synergy server service in foreground

Debugging Synergy Issues

The following “failed to connect to server” is a common synergy service error message.

WARNING: failed to connect to server:
NOTE: connecting to ’nix-dev’: 10.112.10.26:24800

In most case, the above error message is because of the firewall not allowing the client to talk to the server. Modify the iptables rules accordingly to allow port 24800.

If you have’ve installed different version of synergy client and server, you might get the following message. In this case, make sure to install the same version on both server and all the clients.

WARNING: failed to connect to server: incompatible client 1.4
NOTE: connecting to ’nix-dev’: 10.112.10.26:24800

Linux Sysadmin Course Linux provides several powerful administrative tools and utilities which will help you to manage your systems effectively. If you don’t know what these tools are and how to use them, you could be spending lot of time trying to perform even the basic administrative tasks. The focus of this course is to help you understand system administration tools, which will help you to become an effective Linux system administrator.
Get the Linux Sysadmin Course Now!

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

{ 7 comments… read them below or add one }

1 prakash March 20, 2014 at 2:08 am

Nice one…… always pleasure to read tgs articles…..

2 Jalal Hajigholamali March 20, 2014 at 6:20 am

Hi,

Thanks a lot, very useful article
I enjoyed it…

3 chris March 21, 2014 at 1:18 pm

There is also a UI version of the program. You can get it from their site. It makes things a lot easier for the casual user.

4 devender shekhawat March 26, 2014 at 1:57 pm

Thanks a lot…
waiting for new post.

5 Pratik April 1, 2014 at 5:04 am

Amazing

6 damich April 5, 2014 at 3:55 pm

I have been using Synergy for a few months now and it is great. I currently have a Windows machine acting as the server and a Mint machine as a client. The only problem I have is that I can’t get synergy to start automatically during boot on the Mint machine. Any advice on that?

7 Sanjay kumar August 7, 2014 at 4:11 am

@damich: Currently i have wrote script for my setup which i will manually run in each system after booting. I have done alias command in my .bashrc file which i will run as start in each system such as :
alias startc=”synergyc -f nimrodel”
alias starts= synergys -f -c synergy.conf”

but i will write init function today and paste it here soon.

Thanks for comments.

Leave a Comment

Previous post:

Next post: