Most of you know that you can use X-forwarding built into SSH to run a graphical application on a remote host:
laptop$ ssh -X head.mycluster head$ firefox &
(Firefox session displays on your laptop, running on the remote host)
But sometimes these programs run very slowly over the network. Firefox can be slow to render, or a java app may take forever to load. This is due to the many callbacks between the running program and the X server.
Compare that to a local machine, where it is almost instantaneous. This would be a good use case for VNC, which is installed on all of the clusters we build here at Advanced Clustering. You also will need a VNC client on your local computer.
To start up VNC server on the remote machine, e.g. head node of your cluster, simply run “vncserver -autokill”. Note the display number printed out after starting, e.g. head.cluster:1 is display 1. Now, open a new SSH session to your remote machine (you may want to log out of the first one), only this time, you will want to enable a port-forward for VNC. Add “-L 5901:localhost:5901″ to your connection string, e.g.:
$ ssh -L 5901:localhost:5901 head.mycluster
The port numbers are dependent on the display we saw earlier. With display 1, the port is 5901. Display 2 would be 5902, and so on. Change both port numbers, e.g. for :4 our connection string would be “ssh -L 5904:localhost:5904 head.mycluster”.
Now that the tunnel is established, you can connect using your VNC client to localhost, using the display specified. This will bring up a desktop on your remote host. Try your slow application, and notice how much faster it is running. Because the callback delay times are reduced and rendering is all done on the remote machine, applications that are slow over X behave much faster over VNC.
When you’re done, simply log out of your X session. The -autokill option from earlier will have VNC server shut down when you logout. When you close your SSH session, the tunnel to the remote port will tear down as well. If you have trouble connecting with VNC on your cluster, contact us at firstname.lastname@example.org, and we’ll be happy to help.