Remote X11
Posted by danielmeyer on July 8, 2009
I have a main Linux box running Mandriva 2009.1, and I wanted to set up Linux on a second computer in such a way that I could be sitting at the second computer running programs off of the main computer — kind of like remote desktop, only this would be program by program instead of the whole desktop.
I had seen that magic work before (you just ssh to the other computer and run the command, and it shows up in your local display — I think there’s some kind of forwarding going on); but this time I wanted to add a second kind of magic: I wanted the secure shell session to happen without having to drop to a shell and type a password interactively.
I had seen both kinds of magic working before, just not simultaneously.
Magic A
The magic of running a ssh session without having to interactively type a password is explained on the ssh man page. It involves the following steps:
- On the second computer, I ran
ssh-keygen(with no master password, for now anyway). This created (among other things) a~/.ssh/id_rsa.pubfile - I copied the contents of the
id_rsa.pubfile to my home folder on the main computer in a new file called~/.ssh/authorized_keys. - I set the file permissions on the
authorized_keysfile so that only my user had any permissions (otherwise ssh ignored the file and prompted interactively for a password anyway!)
Now I could ssh from the second computer to the main computer without typing a password. The stage was set for Magic B:
Magic B
Now on the second computer I made shortcuts for Firefox and Thunderbird on the main computer. The commands in the shortcuts were:
ssh -f maincomputer mozilla-firefox
ssh -f maincomputer mozilla-thunderbird
Now when I click on those shortcuts, the programs run on the main computer but are displayed on the second computer, only slightly slower than on the main computer (maybe I’ll upgrade to a Gigabit internal network sometime). Nice!