Wednesday 4 January 2012

Running a graphical application remotely using SSH

This finding is in no way revolutionary, but I found it useful, so maybe others will too. I'm running Ubuntu Linux on my laptop, and recently I wanted to run a Matlab script on a Linux workstation. I can log on the the workstation using ssh, for example

ssh martin@server.name.no

which gives me access to the terminal. However, SSH can also be used for graphical programs, if the server is running a X window system. The SSH connection is configured for X session forwarding by adding a "-X" switch at logon,

ssh -X martin@server.name.no

Such forwarding is further explained here. If I logon using the above syntax and start matlab, it appears as a regular window on my desktop, although it's running on the workstation. Unfortunately it can be a bit slow in responding to mouse and keyboard input, so using the terminal version of Matlab may in some cases be just as good.