Ubuntu – using x11 forwarding with ssh and vnc

sshvinagrevncvpnx11-forwarding

I am working on a remote cluster via ssh with the -X option, because I need to visualize data and graphs, over a vpn protocol. Sometime due to the instability of the internet connection I lose my session. They told me I could use vnc in order to not lose my current session, so that if the internet connection drops I can reconnect and continue with my previously open session.

What I do is to log in the remote cluster 'remote.cluster' and type

 vncserver :1

then I open another terminal on my system and I type

 ssh -C -NL 5901:remote.cluster:5901 myusername@remote.cluster &

Then I start vinagre on my system and I connect using ssh protocol. The problem is that I do not have x11 forwarding and I cannot open windows. If I try to connect using the vnc protocol with vinagre it doesn't connect, because I get something as connection timeout.

What should I do?

Best Answer

In case we connect to a remote X-Server via VNC we have the advantage that the graphical application will stay running even when the SSH connection to the remote is down. We can then reconnect to resume the graphical application. See also:

To speed up reconnection we may combine the connection to the remote with an SSH session by using vncviewer from tightvncviewer Install tightvncviewer with the option -via. By this we can run on the remote server:

vncserver:0  ## or any other display number e.g. :1

to establish a connection on the viewer via an SSH tunnel:

vncviewer -via user@remote localhost:0

Doing so will need considerably more bandwith because the whole desktop will have to be transmitted from the VNC server. Therefore it may not really be a good idea for low bandwith connections but it may give you a somewhat better experience on high bandwith but unstable connections as compared with X-forwarding.