VNC via an SSH tunnel

From Devpit
Jump to: navigation, search

In a terminal on the machine where you wish to run the vnc server start a vnc server and pick a session number, e.g. '88':

vncserver :88

VNC uses the number (5900 + session number) for the vnc port. In our example it'd be '5988'.

In a terminal on your desktop set up the tunnel:

ssh -C -L 4900:localhost:5988

In another terminal on your desktop run the vnc client and connect to the port on the left side of the 'localhost' identifier:

vncviewer localhost:4900

If you want to start another session on another machine you'll need to set up another tunnel to a new local host port number. The port of the vnc server can stay the same but the local host port mapping needs to differ from the previous tunnel. We'll use '4901' as an example:

ssh -C -L 4901:localhost:5988

And then connect a vncviewer to the new local host port number:

vncviewer localhost:4901