4

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?

simona
  • 175

2 Answers2

3

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.

Takkat
  • 144,580
1

The command used:

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

forward local 5901 -> remote.cluster:5901

So you can connect to localhost::5901 to connect to the VNC session running on remote.cluster (which you don't have direct access to).

X11 forwarding is different from VNC. You need to use -X, for example

ssh -X myusername@remote.cluster

Than you will be able to run remote GUI applications on your local machine, provided that you have a X Server running locally (Ubuntu Desktop or Xming on Windows).

Update:

I made a mistake in the forwarding, it should be:

ssh -C -L 5901:localhost:5901 myusername@remote.cluster

Then you can vnc to localhost:5901, traffic will be forwarded to remote.cluster:5901. Apology for the carelessness...

If no GUI is required, consider using tmux or screen to avoid loss of session.

Terry Wang
  • 10,185