Tunnel Network Traffic Through SSH

ARRR! Happy Talk Like a Pirate day.

In this scenario, we’re going to tunnel network traffic from a remote Windows box through a Linux firewall to the Windows desktop we’re currently using. The firewall of course has SSH enabled and functioning.

Before we establish a connection with PuTTY, we have to add tunnels for the services we want. The source port will be the local port we connect to and the destination will include the private IP and port number.

For example, let’s get connected to VNC (5900) and browse files (139) on our remote computer (

Note: In order for file sharing to work properly (obviously we’ve got file sharing turned on and configured on the remote end), we’ll need to stop two local services first. From a command prompt, type:

net stop “computer browser”
net stop server

Next, add the tunnel source/destinations like so:

Save, open the connection and login to the firewall.

The moment of truth! Run \\\share_name. If all is well, you should be prompted to authenticate and after a short delay, see an Explorer window open with your files.

And to connect to the VNC service running on the remote host, connect like this:

Remember, these sessions are encrypted and tunneled through the Internet, so they’ll be much slower than if you were on the same network. But I think you’ll be pleasantly surprised.

Note: Remote Desktop (port 3389) does not work through a tunnel as Windows cannot connect to the localhost. You could experiment with the Microsoft Loopback adapter or run Terminal Services on alternate ports, but that seems like a real waste of time given that VNC is so easy to setup.

About Benjamin Perove

Ben has been associated with a broad spectrum of technologies starting from an early age, and he's contributed to the success of many businesses and enterprises professionally since 2001. Most of his time is spent building cool stuff. When he's not working, he enjoys reading, playing acoustic guitar, and being with friends. He currently resides in Medellin, Colombia.

Got WordPress Security?

You will definitely wish you had downloaded my top 5 recommendations when you're cleaning out malicious Javascript from deep within you WordPress site. Enter your email and get the PDF right now, before it's too late.