I have a desktop and a laptop on my workstation, side by side. No KVM switch. Each has its own display, mouse, and keyboard. I thought I could always slide over to use the other computer. Wishful thinking at its finest.
I started investigating KVM options. I like the idea of having both displays visible simultaneously. Therefore, the final solution only needs to share the mouse and the keyboard. Part 1 of this 2-part series focuses on x2x, a software KVM solution for 2 computers. Part 2 is on Synergy, a software KVM solution that supports more than 2 computers.
My primary machine is the desktop which runs Debian 7.5 (aka Wheezy). With x2x, I use the desktop's keyboard and mouse to control my secondary machine, the laptop which runs Ubuntu 12.04 (aka Precise Pangolin).
You only need to install x2x on the secondary machine, the one whose keyboard and mouse you are NOT using.
Before the install, verify that the X Server on your secondary machine supports the XTEST extension.
$ xdpyinfo -ext XTEST |grep XTEST XTEST XTEST version 2.2 opcode: 141
If the secondary machine runs on a recent Debian or Ubuntu release, the install is as easy as:
$ sudo apt-get install x2x
Unfortunately, recent Fedora and other Red Hat-based distributions do not pre-package x2x in their official repositories. This is not totally surprising because x2x is currently not being actively developed. Its most recent release was back in 2003. Part 2 of this series introduces an alternative tool named Synergy that works for Fedora.
If you are successful in installing x2x on a recent Fedora release, please share your experience by leaving a comment.
Before you run x2x, verify that X forwarding over SSH is enabled on the secondary machine. Specifically, the /etc/ssh/sshd_config file on that machine must contain the following line:
Restart the ssh daemon if you had to edit the sshd_config file.
$ sudo service ssh restart
For details on SSH X forwarding, please refer to my earlier post.
Execute a customized version of the following command on your primary machine, the one with the mouse and keyboard that you want to use.
$ ssh -X 192.168.1.111 x2x -west -to :0 email@example.com's password:
The parameters to modify are:
- IP address
This is the IP address of the secondary machine.
- Location of the secondary machine relative to the primary.
My secondary machine is placed to the left of my primary, hence -west. When the mouse crosses the left edge of the primary display, the mouse pointer slides over to the secondary display. From there, when the mouse crosses the right edge of the secondary display, the mouse pointer slides back to the primary. Depending on the relative machine location, you can specify instead -north, -south, or -east.
Now, the two X displays are virtually integrated. Move the mouse of your primary display to the left, crossing the left edge. Notice that the mouse pointer lands in the secondary display. Any keystrokes you enter with the keyboard of the primary display appear inside a window on the secondary.
x2x is not currently under active development. But if your task is to share the keyboard and mouse between 2 Debian-based systems, x2x is a simple and effective solution. If you have more than 2 computers to share, or the computers are non-Debian, or even non-Linux (Mac OS X, Windows), consider using Synergy which is explained in the next post.