Login or register    

SSH Tunnel for HTTP Traffic

Are You stuck behind a firewall?

Does your school, library, work, or parents control where you surf and what ports you have open? Do you surf on such public domains and need more privacy? Are you sick of failing proxies? If you answered 'Y' to any of these questions then this tutorial is for you.

My Story

My place of employment has a firewall and it blocks nearly all outbound protocols and many great sites, such as foxhop.net or youtube.com. I need a way to get around the blocks and not get caught.

Common Questions

What is the best way to get around a firewall?

Create an SSH tunnel from the work network to your home network.

My network administrator is smart, will I get caught?

No, you will most likely not get caught. All the firewall sees is a connection to a resource on the internet. When you browse the web using the tunnel all traffic is encrypted. If a network administrator captured packets he would only get garbage data. An SSH tunnel is basically a VPN between two computers or networks. 1337

Can a network admin stop a person or computer from tunneling?

The Admin will typically not know about the tunnel. From his view a tiny connection is being placed and is normally overlooked. The admin does have the ability to block the default SSH port 22. You can build your tunnel over any port (80 or 443).

Article Scope

We will discuss the steps of building an SSH Tunnel for HTTP traffic between two computers on different networks. This guide will cover both windows and linux localhosts.

Throughout this guide I will use the following terms, here are the definitions:

The computer at work or school.
The computer or server that is offsite, which has the SSH server running.

What you need ...

  1. Credentials to a remotehost running an SSH server. (openssh-server)
  2. A localhost computer crippled by a pesky network firewall.
  3. An SSH client, For windows get Putty.exe
  4. Firefox ( Portable is best )

Why is this the best method?

  1. Most of the configuration is done from the localhost (while at school or work).
  2. You don't need admin rights to run Putty.exe, just place it on a USB drive.
  3. You don't need admin rights to run Firefox Portable, just place it on a USB drive.
  4. No changes need to be made on the remotehost ssh server.

SSH Tunnel created from a Windows localhost

Follow this guide if your localhost (school or work) computer is Windows based.

Configure the SSH Server

The remotehost just needs to have an SSH server installed, no configuration is needed.

This server could be running anywhere on the internet, we just need credentials to login.

To install openssh-server on Debian or Ubuntu linux type:

sudo apt-get install openssh-server

When I'm at work, I establish an SSH Tunnel to my remotehost webserver at home.

Keep in mind that this doesn't have to be your server, you just need credentials for SSH.

Configure the SSH Client

  1. Download Putty.exe if you haven't already, you should follow along.

  2. Double click Putty.exe.

  3. The 'Host Name (or IP address)' box should point to the SSH enabled remoteserver.

  4. Toggle the SSH radio button to set the port to 22. (The native SSH port).

  5. Type a name into the 'Saved Sessions' box to save all the settings we toggle.

  6. Click the save button.

  7. There is a list of categories to the left of the putty window.

  8. Navigate to: ( Connection > SSH > Tunnel )

  9. You should be at a menu that is labeled 'Options controlling SSH port forwarding'.

  10. Click the 'Dynamic' radio button.

  11. Leave 'Destination' text box blank.

  12. Type '7070' into the 'Source port' text box.

  13. Click the 'Add' button.

  14. Save your configuration by going back to the 'Session' category, selecting your saved session, and pressing the 'save' button.

  15. Double-click your saved session.

  16. A black terminal window should appear.

  17. You will be prompted for a username and password.

  18. You should be greeted by the server if successful. Leave the putty window open.

  19. Configure Firefox...

SSH Tunnel created from a Linux localhost

Follow this guide if your localhost (work or school) computer is Linux.

Create the tunnel

Open a terminal or console window, and enter the following command:

ssh -D 7070 user@remotehost_ip

You will be prompted for credentials on the remotehost.

All you need to do is login to establish the tunnel.

Configure Firefox to use the SSH Tunnel

Setup Socks 5 proxy.

  1. Open Firefox.
  2. Click Edit -> Preferences
  3. Click the Advanced and Network tabs.
  4. Click the Settings... button.
  5. Click the Manual Proxy Configuration radio button
  6. In Socks Host type localhost. In port type 7070.

You should now be able to browse the Internet using your remote connection. All data will be passed through the remote hosts internet connection. All traffic will be encrypted between the localhost and the remotehost.

Tunnel to multiple vnc hosts behind a firewall

ssh -L <localport>:<remotehost>:<remoteport> <ssh-user>@<remote>

ssh -L 31337:remote.foxhop.net:5900 user@foxhop.net

ssh -L 31338:remote2.foxhop.net:5900 user@foxhop.net

Then open vnc and point to or

Tunnel DNS requests in firefox


network.proxy.socks_remote_dns user set boolean true

Remote port forwarding a service over tunnel

In this scenario we are running a development web server (port 8888) on our workstation (joe) from our home network. We would like to grant access to this development web server to people on the work network. We have ssh access to a host (mary) on the work network.

  1. We must enable GatewayPorts in mary:/etc/ssh/sshd_config to allow binding to instead of

    # Allow this host to bind forwarded ports to instead of
    # Service will appear to run on this host, but will get forwarded over tunnel
    GatewayPorts yes
  2. We create a remote port forwarding tunnel from joe to mary:

    # -g means gateway -R means remote port forwarding
    # prompt:~$ ssh -g -R <remote-port>:<localhost>:<local-port> <user>@<remote-host>
    user@joe:~$ ssh -g -R 8888: user@mary
  3. When the tunnel opens, verify that mary is binding/listening to

    user@mary:~$ sudo netstat -nap | grep 8888
    tcp        0      0  *               LISTEN      17921/0
    tcp6       0      0 :::8888                 :::*                    LISTEN      17921/0

Now people at work can access the home workstation web server running on joe by connecting to http://mary:8888 !

Note: this only tunnels TCP, to extend this solution for UDP review this



Leave a comment

Please login or register to leave a comment!