Control Linux Boxes With Synergy

Today’s article is the first in a series I call the “Getting work done” article series.

Let’s face it, there are instances where jumping from PC to PC is a bit of a downer – even when it’s something awesome like a Linux PC. Sure, it may not be difficult to walk across the room, but often times it’s disrupts ones workflow.

To counter this unneeded jumping around the room like a frog, I initially thought that remote desktop solutions would be the answer. As it turns out, this wasn’t the case. Using typical remote desktop software to access a computer in the same room is nothing short of overkill.

This brought me to a program called Synergy. Now some might refer you to a hardware KVM switch instead, but I’d would opt for Synergy myself. It’s cross platform, and once you set it up, you’ll never use anything else. Synergy

Setting up Synergy

Before we begin the process of setting up Synergy, allow me to explain what it is. Synergy is software that allows you to use one keyboard and mouse for multiple computers. And like most things in Linux, it works as a background program configured by a conf file. I should also point out that it’s recommended to install Synergy from your package manager to ease its installation onto your system.

Now I’d be remiss of I didn’t mention that there are GUI options for Synergy, such as QuickSynergy. Personally, I think the app is bloated and actually far more convoluted than simply setting up the conf files manually. Consider it this way – if the GUI goes away or breaks, what will you do then? However, if you understand how the conf file works on each computer…fixing any issues will be second nature for you! Sometimes the manual setup method is the best approach. Okay, moving on.

The breakdown of a very basic conf file for Synergy basically comes down to the following.

section: screens
        yourserver:
        yourclient:
end
section: links
        yourserver:
                right = yourclient
        yourclient:
                left = yourserver

end

 

There are several things to note here. First, the two sections shown above. The first section represents the screens we’re going to access. Yourserver represents the PC that you’re sitting in front of, and where you’ll be running the conf file from. Yourclient represents the “remote” machine that is within eye distance, but you really don’t want to bother getting up to use its mouse and keyboard…unless there are some grubbin’ munchies nearby. This would be an acceptable point where getting up is allowed.

Now our next section is called links. Poorly named in my opinion, its flow is actually quite logically laid out for us. In the above example, we see that yourclient is setup to be accessed on to the right of yourserver.

Now, you might be wondering if the first link layout shows how the server/client is supposed to be accessed, why the redundant option below it? On the surface, it’s just required and you need to do it. However, if you want to use more than two PCs in a Synergy configuration, the right and left layouts suddenly make a LOT more sense. Hence, my layout here in my home office.

section: screens
        matt-UbuntuMATE:
        matt-RED:
        matt-plex:
end
section: links
        matt-UbuntuMATE:
                right = matt-RED
        matt-RED:
                left =  matt-UbuntuMATE
        matt-RED:
        right = matt-plex
        matt-plex:
        left = matt-RED
end

A few things to remember here. I’m using each PC’s hostname since I have static IP addresses across the board for each computer on my LAN. And with that, each hostname is carefully selected for ease of remembrance. In my case, my hostnames are recognized between machines. In your case, I recommend static IPs only to keep things simple.

Okay, first we’ll let look at our screens section from my conf layout shown above. Matt-UbuntuMATE is the machine I’m sitting in front of, running my keyboard and mouse. This will be my server.

Next, we have matt-RED. This a little netbook I use for secondary duties, usually recording audio or reading email. This is my second PC in my list of screens and I’d consider this the first client, as it’s directly to the right of my Matt-UbuntuMATE.

And finally, we have my Plex box which is aptly named…matt-plex. This is my second client PC, and it’s directly to the right of the matt-RED PC.

To review, the physical arrangement of my computers in a semi-circle throughout my office is as follows: Matt-UbuntuMATE, matt-RED, and then matt-plex. Following me thus far? Awesome, then let’s install and setup Synergy on your PCs.

Assuming you’re using Ubuntu, you’ll use apt to install Synergy onto your server PC and any client PCs you wish to share a keyboard/mouse with.

sudo apt-get install synergy

Now before we go a step further, let’s save you hours of frustration and make sure your server machine isn’t blocking port 24800 in or out. As for your client PCs, you should not need to change anything. Now that we have our port open, let’s get things running.

First, let’s create our server’s conf file specific for your user and I’m assuming you’re only using two computers.

(Yes, the conf file coming up is stripped down. However, I’ve found this works best and with the least hassles for newcomers.)

Open up a terminal window.

cd ~/
touch .synergy.conf
nano .synergy.conf

In the new file, create the following (substitute my hostnames for your IP addresses)

section: screens
        yourserver:
        yourclient:
end
section: links
        yourserver:
                right = yourclient
        yourclient:
                left = yourserver

end

If instead, you have three computers, you can emulate my setup shown above.

Now save the file, then we’re ready to test our configuration.

On your server box, run this in its terminal window:

synergys -f

Now I chose to append -f as I want to see any successful or failures happening. At this point, you’ll see it trying to connect…but it can’t because we haven’t setup the clients just yet.

On both the client PC, run this in its terminal window:

synergyc -f IP-of-your-server

Example: synergyc -f IP-of-your-server

Again, the -f allows us to see what’s happening. If you’re successful, in the server’s terminal, you’ll see something like “client “blah, blah” has connected. Verify this on your client machine as well: connected to server. Because we ran both synergys and synergyc with the appended foreground option, it’s going to continue to spit out the same thing over and over in the terminal.

Auto-starting synergy

For me, I like to run synergy at the system boot. And since I run Ubuntu MATE, I simply run the following on the server’s startup application preferences.

synergys &

As for the client, I’ve found that in some cases it pays to simply point the startup to a script. This allows me to add stuff like sleep, etc. You can download the script from this link, then add it to your start up (with the script’s full path in the executable area.

Or simply add the following to your startup instead:

synergyc server-IP-Address &

Advanced options, encryption and other considerations

This only scratches the surface of what you can do with synergy. As of version 1.7.x, the encryption was enhanced using SSL. Despite my best efforts, I’ve never had it working. That said, you can learn about it here.

“But what about this thing I read about elsewhere called ‘aliases’?” Aliases are a section that can be added to your config file should your server not recognize your client’s machine’s host name. To be completely honest, using this function just complicating the issue for the first time synergy user and I recommend sticking with static IP addresses for now. I honestly don’t see any value with aliases for most people. Your experiences may vary.

If you want to dive head first into everything you can do with Synergy and really play with it, go for it. You can learn nearly everything it can do from Arch’s great documentation. But, if you’re new to Synergy…this article will get you running without pulling your hair out of you head.

Troubleshooting

Problem: It seems to be running during the tests you described Matt, but it’s saying it can’t connect to anything!

Solution: Make sure your port 24800 is open on your server PC. In rare cases, you may need to do some forwarding with your router from server to client, port 24800. I’ve never needed to, though.

Problem: Synergy worked one day, then it failed the the next time.

Solution: Turn off the server and client. Turn on the server first, then after the boot completes…start the client. This should work if both are successfully setup to run the autostart configuration mentioned previously.

Also check out...

Matt Hartley
Founder at Freedom Penguin
Freedom Penguin’s founder & talking head – Matt has over a decade working with Linux desktops, his operating system experience consists of both Windows and Linux operating platforms. In addition to writing articles on Linux and open source technology for Datamation.com and OpenLogic.com/wazi, Matt also once served as a co-host for a popular Linux-centric podcast.

Matt has written about various software titles, such as Moodle, Joomla, WordPress, openCRX, Alfresco, Liferay and more. He also has additional Linux experience working with Debian based distributions, openSUSE, CentOS, and Arch Linux.