Using VNC through SSH

On occasion you may want to connect to a machine at the office and use applications on it. You can do so using VNC. Often though most organizations will block VNC traffic and allow SSH therefore you'll need to use SSH forwarding to tunnel VNC. To do so follow these directions

1) Log into a machine where you want to start a VNC session.
2) Start vncserver on machine called remoteserver


You will get something like this

New 'X' desktop is remoteserver:1

Starting applications specified in /home/vuksan/.vnc/xstartup
Log file is /home/vuksan/.vnc/io:remoteserver.log

This will launch VNC service on port 5901 (VNC ports start at 5900 + the number of the display in this case 1). TightVNC will also launch a webserver on 5801 to which you can connect through your web browser.

3) Set the VNC session password. Execute


Make sure you set a secure password.

5) On your home machine download the TightVNC client from
6) SSH into the remote machine or machine that is a gateway for your network and use SSH forwarding ie.

ssh -L 5901:remoteserver:5901 remoteserver

7) On your home machine you can now execute

vncviewer :1

This will in turn forward your connections through the SSH tunnel to remoteserver:5901 which is running VNC.

Once you are done with your remote session you need to kill it on remoteserver. Simply closing the vncviewer will leave the session open. Ssh back to remotserver and execute

vncserver -kill :1

Author: Vladimir Vuksan E-mail me