What this guide will help you do:
This guide will help you control two separate computers with one mouse and one keyboard, utilizing SSH and a little known tool called x2x.
What this guide will not help you do:
This guide will not help you set up a dual monitor system (One computer with two monitors.)
Advantages of this method over a dual monitor:
As said before, you will be controlling two separate computers. This means that both computers can be running completely different OS's, WM's, etc. This also means that you will have the combined hard drive space of both boxes.
Disadvantages of this method:
The only real downside to this is the fact that you can't drag anything from one screen to the other. (Of course there are other methods of transferring files, and I'm sure it is quite possible to set up a script that can be added to the nautilus right click menu for transferring files to the other box. However, this is beyond the scope of this guide.) If you are looking for simply a bigger desktop, with the capability to drag windows and such, then this is not for you, and you should look into a dual-monitor setup.
With all that out of the way, let me explain how this works. Basically, you establish an SSH session with the computer you wish to control with the mouse/keyboard connected to your main box. Once connected, you run a program called x2x, which allows the cursor to "jump" to the second box when you move the mouse to the edge of the first screen, and vice-versa. Theoretically, this link could continue through infinite computers, meaning you can control three, four, five computers with one mouse. (Why you would have five computers on one desk is beyond me, although I wouldn't mind =])
Okay, down to the nitty gritty.
The first thing we need is all required packages. Plunk this in a terminal;
Code:
sudo apt-get install openssh-server x2x
Now we need to set up a trusted pairing of the two computers, to avoid inputting a password every time you initiate the connection.
Edit: These packages must be on both boxes. (Not so much x2x, but it's good to have it on both. openssh-server is a must on both.)
Press enter to accept the default file location, and then press enter twice for a null passphrase. You should now have the file "id_rsa.pub" in ~/.ssh. We need to copy this to the other computer as ~/.ssh/authorized_keys. To do this, put the following in the terminal:
Code:
scp ~/.ssh/id_rsa.pub user@host:/home/user/.ssh/authorized_keys
Of course, substitute "user" with your username on the second box (unless it is the same as it is on the local machine, in that case you can just start with the host), and substitute the IP address of the remote box for "host."
Okay! Now you should be able to SSH into the remote box without a password. To test it, just run the following:
And it should connect without any prompts.
Everything good so far? Good. The hard parts done. Save the following two scripts in /bin:
Name the following script "startxshare".
Code:
#!/bin/sh
ssh -X host x2x -east -to :0 &
(This is assuming that the second computer is to the right of your first. If it is not, simply change east to west.)
Name the following script "stopxshare".
Code:
#!/bin/sh
pid=$(ps aux | grep "ssh -X host" | grep S | awk {' print $2 '})
kill -9 $pid
Naturally, you will probably want to set up a static IP on at least the second machine, if not both. If it's dynamic, then the scripts will have to be changed whenever your IP changes, rendering the script useless. (Unless of course, you write a script to automatically update the X scripts, and that, although possible, can get tricky.)
Also, it should go without saying, but I'll say it anyway, set both scripts to executable:
Code:
sudo chmod +x /bin/startxshare
sudo chmod +x /bin/stopxshare
Finally, you want to make sure that X Forwarding is enabled. It should be by default, but cant be two careful.
Code:
cat /etc/ssh/sshd_config | grep Forwarding
If you see "X11Forwarding yes," you're ready to go. If not, do change it.
Ready for the magic? Hit alt+f2, or open a terminal, and enter "startxshare." Now move your cursor to the desired screen edge, and all should go well. To stop it, just enter "stopxshare."
Any questions? Ask away!
-Gotti
Bookmarks