Secure VNC for free

Here are my instructions on how to get VNC in KDE 3.5+ working through an SSH tunnel. It’s easier than you might think.

To start all you need is 2 or 3 Linux machines with OpenSSH installed. Most distros come with it (although I know Ubuntu does not).
NOTE: All my machines run Slackware 12.0 or higher.

Step 1 – Setup the host.
This is fairly simple, open up you Control Center, and find Desktop Sharing. Just look at my picture below and see the settings I would recommend for this.
Just make sure you set a STRONG password!

Now comes the fun part. Creating the SSH tunnel. By default the VNC connection is on port 5900.
For this example you have 2 computers. Your at a coffee shop with free wifi but your smarter than everyone else, so your going to use encryption to your home desktop and surf the internet from there.
Your home computer (lets say) has a domain name. For my examples it will be, and your internal computer is
Make sure you set your router to forward port 22 (the SSH default) to
Open up a terminal (some times it’s called Konsole) and type:

ssh -L 5931:localhost:5900

The user name I’m using is dkun, just put in your user name
You will be prompted for your password, after entered you have formed the SSH connection. What this command does is it takes all traffic from your desktop port 5900, and forwards it to your laptop (at the coffee shop) to localhost port 5915.
Seems complicated, but trust me, it works!
Now open up Krcd and type


Just as shown below.
If you have 3 computers. For example, you don’t forward to your desktop (for security reasons) but you do forward to a file server. Lets say your file server is and your desktop if type:

ssh -L 5915:

This will form the SSH tunnel to your server ( then forward port 5915 from through the SSH tunnel back to you.
Reminder: Doing it this was results in plain text from to This is only a problem if you don’t trust your internal network!

From here is gets simple, after you click Connect you will be prompted for the following window.
These are the settings I recommend for over the Internet, VNC can take a lot of bandwidth.
Next you will get a password prompt, type in your password and hit OK
Your remote desktop will appear! if you look quickly you will see this at the bottom right of the screen
That’s it! Now you can use your remote desktop over a secure connection!
WARNINGS! If you attempt a connection without the SSH tunnel your passwords will be sent in plain text! That is BAD!

Extra Notes: If you do not have a domain name to work off of, you can put in an IP address after the username@, make sure it’s an internet IP address, will NOT work
If you don’t have a static IP address you can use dyndns to get you one. They are really good, but if your IP changes you will have to update your opendns account. I would recommend checking before you head out.

Special Thanks to Spyder_3lite of If it weren’t for you showing me something way cool with SSH, I never would have been able to do this.

Note: This was originally written on my other site I have moved it here for better indexing from Google. ^_^

Leave a Reply