In this article, I will talk about how you can tunnel any VNC connections over the SSH protocol, which ensures all traffic is encrypted and secure. I currently use this all the time before remotely connecting to any of my PC’s so that passwords and login info cannot be sniffed.

There are a few prerequisites that have to be completed before you can really use the information in this article.

1. SSH Server – Firstly, you have to setup a personal SSH server that will be used to create the secure VNC tunnel. That is beyond the scope of this article, but you can read a great post by LifeHacker on how to setup a personal SSH server. (That guide is more than a decade old, but still works. A different blog has a newer guide that also works.

2. VNC Server – Secondly, you need to install and configure a VNC server on each machine that you want to connect to.

3. Dynamic DNS – Lastly, if you want to be able to connect to your home computer from outside the local network, you will need to setup a free dynamic DNS account, unless you have a static IP already. You can read my earlier post here on how to setup dynamic DNS. This will allow you to use a unique domain name like myname.homeip.net, etc.

That might seem like a lot of stuff to complete before you can do this and it is! It took me a while to learn everything and get it all working, but once it’s setup and it works, you will feel like you just climbed Mount Everest!

The order in which you would want to complete those three prerequisites is setup dynamic DNS, then setup the VNC server software (fairly straight-forward), and then setup the SSH server.

Tunnel VNC Over SSH

OK, now to the tutorial for learning how to tunnel VNC over SSH! In this article, I will be using TightVNC as my remote control software and Putty as the SSH client. We will use Putty to connect to the SSH client and then use TightVNC to connect to the computer we want to control.

Step 1: Open Putty and click on the Session category in the left pane. In the Host Name box, you need to type in the dynamic DNS address for your home SSH server. Or you can type in the IP address if you have a static IP. Note this is your external IP address for the SSH server.

Also, type a name into the Saved Sessions text box like VNC over SSH and click Save. This way, you won’t have to do this each time.

vnc over ssh

Step 2: Now expand Connection, then SSH and click on Tunnels. Now type in the source port number and the destination port. The source port for TightVNC is 5900 because that is the port it listens for connections on.

The destination port will be the internal IP address for your SSH server followed by the same port number, i.e. 10.0.1.104:5900.

vnc over ssh putty

Step 3: Now click the Add button and it will show up in the list box directly above:

vnc over ssh tunnel

Step 4: You don’t need to change anything else. That’s it really! Now go back to the Session screen and click the Save button again.

You can test it by clicking Open and you should get a command window that asks you for your username and password. After logging into the SSH server successfully, it will bring you to the command prompt. Now you have created a VNC over SSH tunnel!

Step 5: Now open TightVNC and type in 127.0.0.1 in the VNC server field:

tightvnc ssh

Now click Connect and you should be able to connect to your computer remotely! It’s a bit of a process and a little complicated, but if you keep trying, you will get it to work! Once you get the SSH server setup, you can also use that for encrypting your web browsing session!

If you have any questions or can’t figure something out, post a comment and I will try to help you out! Enjoy!

Comments [4]

  1. hi,

    i configured tunnelling using freesshd + Tight VNC SERVER on my server PC (LAN) and client PC (LAN) with tight vnc viewer and putty!! tunneling was straight forward, problem occured when i tried to establish a connection from client to server by entering 127.0.0.1 in tight vncviewer. it never displayed anything at all

  2. Hi, I understood your points and it works when I connect VNC client in forward connection. Can you tell me how to verify that VNC client and server(on UNIX side) is communicating over SSH?

    Thanks,

    Dipti

  3. Didn't work when I connected VNCviewer to 127.0.0.1 after setting up SSH tunneling. "Connection Refused."

  4. @mike restarting the ssh-server fixed the problem for me.

    Im using freesshd with tightvnc and putty

    configuration as in the tut,

    my problem is, that the connection always crashes after a few clicks in the vnc. Putty tells me "software caused connection abort" and VNC tells me "SocketIPv4 error while reading"

    I have absolutely no idea what's happening and how to fix this.

    btw. connection is absolutely stable.

    The SSH session also crashes after a few commands ("tasklist" on the shell works max. twice) then same error as above.

Comments are closed.