Tuesday, January 9, 2007

Run X11 Applications Remotely

Sometimes you want to run a graphical application on a Linux box that is headless, but you don't want to go to the bother of connecting up a keyboard, mouse and monitor. The Linux graphics system X11 is great for this as it doesn't care where you are, as long as it is knows where to connect and is authorised to do so. Here is how I run X11 applications locally on Mac OSX or Linux:

First off, I start the X server. On OSX that means installing and running the application; on Linux I'm usually already in a graphical mode so it is already running. On the local computer (the one I'm sitting at) I run:

$ xauth list
Ari.local/unix:0 MIT-MAGIC-COOKIE-1 7b246eec9fc9d493fc009dd4ea2b8b8a
10.0.0.9:0 MIT-MAGIC-COOKIE-1 7b246eec9fc9d493fc009dd4ea2b8b8a
localhost:0 MIT-MAGIC-COOKIE-1 7b246eec9fc9d493fc009dd4ea2b8b8a

The line in the middle is the one of interest; it is the inet domain line. Copy that line. On the remote computer (via ssh) I run

$ export DISPLAY=10.0.0.9:0
$ xauth add 10.0.0.9:0 MIT-MAGIC-COOKIE-1 7b246eec9fc9d493fc009dd4ea2b8b8a

That second line is mostly a copy-paste job. Once all this has been configured, X11 should now run lovely.

2 comments:

Gavin said...

use ssh -X to connect to the remote host and your display is set automaticly, and more importantly, the X11 connection is tunneled over the ssh connection !

A nifty tool

Phill said...

Thanks for the comment! I've found that this works on Linux but not on OSX - it may be my particular setup though.