Sign in
in
   

Tags

No tags have been created or used yet.

Monthly Archives
 

Warning:

This article is more than 45 days old. Given the speed at which the technology world moves, this post is probably somewhat out of date. Please keep this in mind when reading the post. If this is a tutorial, please check whether you are using the same versions mentioned in the article.

SSH Tunneling (on Windows) with OpenSSH and Putty through an HTTP proxy

I became interested, a little while ago, in how to tunnel encrypted traffic through an http proxy and firewall with only the standard open ports (80, 443).  There are a number of reasons to do this, basically anyone sniffing or logging will not be able to tell the difference between the tunnelling and regular https traffic.  It will appear as one https session to a destination address.  I'll leave it up to all of you to figure out the useful scenarios.  In any case, I wasn't able to find any documentation that explained how to do this simply, so here we go:

In this example, I'll use two machines workComp - a winxp computer sitting behind the standard corporate firewall with only proxied http and https access, and homeComp - a winxp computer sitting behind a router/gateway running NAT and a simple blocking firewall (e.g. linksys).

Step 1: Download and install OpenSSH

On homeComp download OpenSSH for windows from: http://sourceforge.net/project/showfiles.php?group_id=103886&package_id=111688/ Follow the instructions and install it.  Once its installed configure it according to the documentation- be sure to use a strong password/username because it will be visible to the internet (although disguised in a way, as I explain in a bit.)  Once you're sure that it is working correctly (test it using ssh localhost, and you can get to a shell) it is time to configure it for the tunneling.

Step 2: Configuring OpenSSH

On homeComp edit the file c:\program files\openssh\etc\sshd_config.  Note the file name is sshd_config and NOT ssh_config.  So in the sshd_config file, you want to make 2 important changes:

1. Uncomment the port line and change it to 443.  This is very important if the http proxy that workComp is behind is doing anything at all to detect tunneling.  Basically, this disguises the connection so the proxy thinks its a regular https connection.  I've found that these things implement some of the worst security I have ever seen - check out http://www.bluecoat.com/downloads/support/BCS_tb_tunnelling_applications.pdf if you want to have a laugh, they control tunneling by verifying the user agent header and port on the destination.

2. Uncomment the line with AllowTcpForwarding, and set it to yes.  This will allow the forwarding to take place.

Step 3: Configure port forwarding on the router (on homeComp net)

1.  You now have to configure port forwarding on your router so you'll be able to access homeComp from the internet.  Go to your port forwarding setup on the router and set to forward all 443 TCP traffic to the nat'd IP of homeComp (ex. 192.168.100.1).

You're now finished configuring homeComp - next are the steps for workComp.

Step 1: Download Putty

1. You can get putty from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html - install it.

Step 2: Configure Putty for use with the proxy

1. Under the session tab enter the external IP of homeComp - this will be the router's ip - you can get this from going to status or something of the like on your router.  This should not be a 192.168 address.  Enter the port as 443 (this is going to fool the proxy).  Next set the protocol to SSH.

2. Now go down under Connections and pick your proxy type (I used http, but you may want to pick something else if you are behind a socks proxy).  Enter in its hostname and port.  If you don't know what this is check the proxy settings for your web browser, this should give you all the information you need.  It'll probably be 8080..

3. Under the SSH tab set the protocol for version 2 and move AES encryption up to the top with 3DES below.

4. Now under the SSH tab, click on Tunnels - this part gets a bit confusing.  Source port is the port on workComp you want to forward over the tunnel and destination should be localhost:port.  This is because when homeComp gets the forwarded packets, it will forward it to localhost:port - which will be homeComp:port - exactly what we need.  This is also interesting, because we could set it up to forward to a 3rd machine, I'll leave that one up to someone else with some good ideas.  When your done, click add and you should have something like “L5900 localhost:5900” - I set up this forward so I can use VNC from workComp to connect to homeComp.

5. Remember to save your session, up on the main session tab, as it is quite annoying have to type all these settings in every time you start up putty.

Step 3: Connect!

1. If you've done everything correctly here and you can get out on workComp, just fire up putty and click connect.  You should be able to connect to your homeComp and get a shell up.  But there is one final task, start up the tunnel for whatever app you configured in forwarded ports.

2. Open the app which you configured your tunnel for (in Step 2.4 - on the workComp) and connect to localhost on specific port.  For tightVNC connect to localhost:5900, if we wanted to tunnel out http, we would configure our browser to use localhost:8080 and set up the similiar rule in putty.  Putty will grab the request, encrypt and tunnel it over https.  Ding.  You’re done.

Somehow I think this ended up much more confusing than I meant - let me know how I can clarify this more, or of any confusing parts and I'll fix it up.

Dave
Only published comments... Nov 27 2006, 01:15 AM by Dave

View related posts

 

Adam said:

I set this up a few months ago through an HTTP proxy-works awesome...

December 8, 2006 5:24 AM
 

tdaggs said:

Hi Dave, great howto and simple to setup. perfekt.

regards

tdaggs

January 8, 2007 11:49 PM
 

Knox said:

I've been using a setup like this for almost 6 months now to avoid big brother.  Another tip is to use something like firefox portable from www.portableapps.com so that there is no trace of your browsing left on your work machine either.

January 10, 2007 5:41 AM
 

Dennis said:

Hi,

I've done everything you said and it works fine for RDP. I forwarded workPC:3390 to localhost:3389. I now can takeover my homePC. Now I want to browse the internet through the tunnel. I added a dynamic port (8080) to the Tunnel section of the SSH tab. When i change my browser setting to connect through localhost:8080 the event log of Putty shows:

Opening forwarded connection to workProxy:80

Forwarded connection refused by server: Connect failed [Connection timed out]

Is there something i did wrong? Should i forward workPC:8080 to homePC:443 then port on which ssh is running? Maybe you could help me.

Kind Regards,

Dennis

February 9, 2007 2:36 AM
 

Fred said:

On the  system with openssh in the sshd_confg file, you wll need to make sure that

  AllowTcpForwarding Yes

Is there  and not commented out (has a # in front of it)

July 30, 2007 5:33 PM
 

Denis said:

If I don't use a router, can I just jump over the "router configuration" part?

I use ADSL, and I have a modem.

November 17, 2007 5:14 PM
 

STEG said:

Great article it worked for me.

If you would like to proxy http traffic through your browser you can setup the putty tunnel with source port only and select the dynamic option. When you click add it will look like D5900.

November 30, 2007 2:33 PM
 

Denis said:

Can anyone answer my question? it's up there.

>If I don't use a router, can I just jump over the "router >configuration" part?

>

>I use ADSL, and I have a modem.

December 3, 2007 6:40 AM