SSH Tunnel through HTTP proxy

You are behind an HTTP proxy that doesn’t allow you to access certain sites and you want to access them anyway’s.

This is your current situation:

before

You can accomplish this through a SSH tunnel. After I explain how to do it you will be in this situation:

after

 

What you’ll need is:

  • PuTTY, or another SSH client able to tunnel through HTTP;
  • An SSH server on the external side of the proxy, configured so you can tunnel through it.

After you configure PuTTY it will work as a proxy that will forward all your requests to the SSH server that, in turn, will forward the request to the site you want to access.

The configuration of the SSH server is beyond the scope of this article. The only thing in need of configuration is PuTTY, so here it goes:

Let’s begin by starting PuTTY. Fill in the host name or IP address of the SSH Server and the port it’s running on (default is 22). You probably want to use this settings again in the future so you should name the session appropriately. Your window should look like this (change the names to your specific needs):

PuTTY-1

Now let’s configure the proxy settings under the “Connection” branch. Set the proxy type to HTTP and fill the “Proxy hostname” and “Port” fields with yours:

PuTTY-2

The preferred SSH protocol version should be set to “2″ or “2 only”:

PuTTY-3

And now the most important part: the tunnel. Here you will set the port where PuTTY will listen to you’re client (eg: browser) requests. Since we want our SSH server to forward our requests to the target server, independently of the protocol we use (HTTP, POP3, SMTP, etc.) let’s set the forward port type to dynamic and choose a source port number that’s not in use in the PC:

PuTTY-4

And that’s it for the tunnel configuration. We just set up PuTTY to work as a SOCKS proxy.

Now we have to configure our client(s) to use our tunnel. This is an example of the Firefox configuration dialog:

ConnectionSettings

Finally start your PuTTY session and login to your SSH server. Point the browser to the sites you were unable to access and enjoy.

Leave a Reply