How to connect to/setup VNC via tunnel over SSH

If you want to connect to vnc via an ssh tunnel, you must have a user account on the machine running vnc server. You should also know that which display the vnc server is running. These details can be found in /etc/sysconfig/vncservers or via the ps command output.

  • Use the following SSH command to connect to vnc server.

ssh -L 590X:127.0.0.1:590Y -N -f -l user-name server-name

  • Make sure to replace Y in the above command with the display number on which vnc server is running. With the new versions of vncviewer, you can create ssh-tunnel with the -via flag.

vncviewer -via user-name@server-name server-name:1

Leave a Reply