This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Tools & Utilities

x2x is a software alternative to a KVM switch

By David Pendell on September 30, 2008 (4:00:00 PM)

Share    Print    Comments   

Unless you have fully embraced the virtualization movement, you probably have more than one machine in your home or office, particularly if you run more than one operating system, and you probably have more than one keyboard and mouse on your desk. If you would like to regain some desk space without having to purchase a KVM switch, x2x may be the solution. Simply put, x2x takes advantage of the X Window System's ability to run a display over a TCP/IP network. In this case, you are not running a display as much as you are taking charge of another display's mouse and keyboard.

You can run x2x over SSH, which is easy and secure, or connect x2x directly to the remote X server. The second method is a bit more difficult because it requires some reconfiguring of your X system, but it gives you the ability to cut and paste between the systems. If you want x2x to be as secure using the second method as it is with the first, you have to resort to SSH port forwarding, which may be difficult because x2x does not use a consistent port on the primary machine. In either case, the machines that run x2x have to support the XTEST X Window extension. Most Linux distributions do; to see if yours does, run the command xdpyinfo | grep XTEST in a terminal. If you get any response, you are over the first hurdle.

To install x2x in Ubuntu or any Debian-based distro, run the command sudo apt-get install x2x. Unfortunately, Fedora 9 does not include x2x, but Fedora 8 does, and it installs in Fedora 9 without dependency problems. I used the package from the Dries RPM repository. For any other distro, look for x2x in the package manager. Compiling from source may not be an option, because the download links on the project's home page don't lead you to the code. The project hosts a Mercurial repository, but the code there is for the unstable 1.30 beta version. If you want the stable 1.27 code, you will have to look for it in a distro repository. The two versions of x2x use different protocols, so make sure the versions on your machines match.

To use x2x, you need to have a secure shell daemon running on the remote machine. For both Ubuntu 8.04.1 and Fedora 9, the SSH daemon should already be installed. If it's not, in Ubuntu, either install it using Synaptic, or run the command sudo apt-get install ssh. For Fedora, run the command sudo yum install openssh.

One additional caveat: If you are using a login manager such as gdm, you must enable remote TCP connections to the X server. In Ubuntu 8.04.1 run the command sudo /usr/sbin/gdmsetup. Select the Security tab and uncheck the "Deny TCP connections to the Xserver" checkbox. For Fedora and other distros, consult the documentation for the X server and login manager. A quick check of netstat -a | grep x11 will tell you if you need to investigate further. If the result comes back containing LISTEN, you should be ready to go.

Once all of the dependencies are satisfied, setting up method one is simple. First, determine the orientation of the displays -- will the remote display be north, south, east, or west of the primary machine? On the machine that hosts the keyboard and mouse, run the command:

ssh -X remote_machinename_or_ip_address x2x -direction_of_the_remote_display -to :0

On my test machine, since the remote display was to the left of the primary display, I used the -west option. If all goes well, a prompt for your password on the remote machine should follow. Enter it, and you should be able to move the mouse to the edge of the primary display and have it appear on the remote display.

One advantage to this method is that the only machine that requires x2x to be installed is the remote machine. As a test, I disabled x2x on the primary system and tried connecting and running x2x through SSH. It worked perfectly. This is very handy if the primary machine limits your access to configuration files.

Method two is a little more complex, but potentially worth it if you can gain the ability to do cut and paste between machines. On my test rig I was never able to get that functionality working, and unfortunately, good documentation for x2x is limited.

With the second method, before you can connect to the remote display, you have to add the IP address or hostname of the primary machine to the xhost authentication on the remote machine or the primary machine will be denied access. To do so, run xhost IP_or_hostname at the command line on the remote machine. If there are no errors, carry on; otherwise, look into security settings on the remote machine. Once you're successful, run the following command on the primary machine:

x2x -to IP_or_hostname:0.0 -direction_of_the_remote_display

You should then be up and running. Move the mouse to the edge of the screen in the direction that you chose. If all goes well, the mouse will disappear from the primary machine and appear on the remote machine. Try cutting and pasting; if it works, great! If not, well, don't say I didn't warn you.

If all you want is quick access to more than one display on different machines with one keyboard and mouse, x2x works well, particularly if you have root access to only the remote machines. If you absolutely must have cut and paste, or your machine mix includes Mac OS X, you may want to consider Synergy instead.

David Pendell has been working with computers for the last 23 years in a variety of capacities, including for programming and audio and video processing. He has been using Linux since Red Hat 5.1 and has used a variety of distros.

Share    Print    Comments   

Comments

on x2x is a software alternative to a KVM switch

Note: Comments are owned by the poster. We are not responsible for their content.

x2x is a software alternative to a KVM switch

Posted by: Anonymous [ip: 203.24.97.9] on September 30, 2008 04:52 PM
How is x2x a KVM replacement?? A KVM switch is used to use a single mouse, keyboard and monitor over several computers and can be, in theory, used on any number of computers - x2x requires a multi-head display and can only support 2 (and requires that the computer that is connected to the monitors is on)

#

Re: x2x is a software alternative to a KVM switch

Posted by: Anonymous [ip: 117.195.32.128] on October 09, 2008 01:19 PM
It is not, but it makes a good title to attract unsuspecting readers :) </sarcasm>

#

x2x is a software alternative to a KVM switch

Posted by: Anonymous [ip: 92.42.145.164] on September 30, 2008 05:04 PM
How is this different to standard X11 forwarding?

#

x2x is a software alternative to a KVM switch

Posted by: Anonymous [ip: 207.206.133.254] on September 30, 2008 05:13 PM
For a better alternative, I would recommend synergy @ http://synergy2.sourceforge.net/

#

Re: x2x is a software alternative to a KVM switch

Posted by: Anonymous [ip: 4.227.192.191] on September 30, 2008 10:04 PM
Did you read the article? It mentions Synergy at the end. Don't comment unless you read the whole thing, huh?

#

x2x is a software alternative to a KVM switch

Posted by: Anonymous [ip: 81.208.74.179] on September 30, 2008 05:49 PM
yep synergy is good also

#

x2x is a software alternative to a KVM switch

Posted by: Anonymous [ip: 76.103.40.20] on September 30, 2008 05:51 PM
Is x2x really worth it? Synergy is a much better option for multi-head setups because it supports more than 2 systems and works on Linux/Windows/MacOSX. 2-port USB KVM/audio switches (with cables) are available online for under $15.

#

x2x is a software alternative to a KVM switch

Posted by: Anonymous [ip: 216.201.146.66] on September 30, 2008 05:59 PM
Synergy works awesome for me, I have a bunch of old laptops that I've setup and I can just move around to any of them. Synergy's instructions for hooking up to a mac kinda suck right now but I sent them a work around that involves applescript that makes it a whole lot easier. If you need it and don't see it in their docs, try contacting them for the fix.

#

x2x is a software alternative to a KVM switch

Posted by: Anonymous [ip: 216.123.208.30] on September 30, 2008 10:25 PM
I just ssh into multiple machines from multiple virtual desktops in KDE. I don't see the point of having yet another layer of obfuscation going on.

#

x2x is a software alternative to a KVM switch

Posted by: Anonymous [ip: 129.78.149.91] on October 01, 2008 06:06 AM
KVMs do offer one advantage. When the network up and dies, it doesn't nuke the control to your machine. This is just running a headless box in reality. If you really need a Desktop, SSH using -Y (unrestrictive X11 forwarding) and gdmflexiserver is not bad.

#

x2x is a software alternative to a KVM switch

Posted by: Anonymous [ip: 78.32.151.57] on October 02, 2008 05:17 PM
Some posters have the wrong idea, at least regarding Synergy, and reading the article I gather x2x is the same. You have a display on each machine but one keyboard and one mouse.

You set the system up so that as you move the mouse to the edge of the screen it hops to another screen i.e. computer, thus transfering keyboard input to that system at the same time.

I have my main Linux box's screen sitting above an old laptop with no keyboard. As I move the mouse to the bottom of my main system's screen it simply disappears from that screen and appears immediately on the laptop below.

The point is you have full visibilty of all displays all the time. Synergy simply allows you to transfer control from one computer/screen to another by moving the mouse. Personally, I wouldn't be without it!

#

x2x is a software alternative to a KVM switch

Posted by: Anonymous [ip: 202.28.51.71] on October 05, 2008 09:47 AM
When install new operating system. Can it replace KVM?

#

x2x isn't a software alternative to a KVM switch

Posted by: Anonymous [ip: 69.126.38.25] on October 07, 2008 11:28 AM
Am I the only one who doesn't run X on some machines? I suppose no one else has ambitions of running their own cluster, or if they do they'd like to run X on each machine for God knows why, sadly. I think I'll stick with my 4-port KVM.

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya