Monday, November 06, 2006

Controlling Two Computers with One Keyboard and Mouse

The x2x program allows the keyboard and mouse on one X display to be used to control another X display. It also shares X clipboards between the displays. Basically this allows you to have two machines sitting side-by-side and use a single keyboard an mouse on them.

I choose to use ssh tunneling as the authentication mechanism between them. The first step is to setup passwordless ssh in both directions between the two machines. Then, I copied one of the quick-launch buttons on the GNOME menu bar to the menu bar by control-dragging it and edited the copy to have the following settings:


ssh OTHER_MACHINE_NAME DISPLAY=:0.0 ssh -X THIS_MACHINE_NAME x2x -from :0 -east&

Control the other display with this mouse and keyboard

Clicking the launcher will then run x2x and allow the mouse and keyboard to control the other machine. I used the -east command-line switch because my "other" machine sets to the right of "this" machine. So when I move the mouse off of the "this" screen to the east, right, it appears on the "other" screen and vice-versa.

UPDATE: If this is run more than once, there will be multiple instances of ssh running on the remote machine. This can happen if the connection is lost for some reason and then reestablished. (Changing the remote machines firewall settings will do this.)

A simple workaround is to kill or killall the ssh session(s) on the remote machine and then rerun this again. Before doing a killall ssh on remote, manually close any local ssh connections to the remote machine to avoid losing any unsaved data.

No comments: