Skip to content
Solely for the Purpose of Catching $PAMRZ

Note to Future Self: Use `ssh -D` to bypass annoying interception proxies

Dear future self,

If you are reading this, you are remembering a time when you ran into a really nasty interception proxy1 and you are looking for a way around it. Do you remember when you were sitting in the Denver International Airport using their free wireless service? And remember how it inserted advertising banners in HTML frames at the top of random web pages as you surfed?

After about a half an hour of this, you started looking for solutions and found that the secure shell client can act as a SOCKS proxy2. Using ’ssh’, you set up a tunnel between your laptop and a server in the office that encrypted and effectively hid all of your network communications from the interception proxy. And if you are reading this again you want to remember how you did it.

Set up the SOCKS proxy

SOCKS is a client protocol that can be used to tunnel all of your traffic to a remote host before it fans out across the internet. The OpenSSH client can set up a local SOCKS proxy that uses an ’ssh’ session as the network tunnel. To set up the tunnel, use the -D option followed by a local port number:

ssh -D 9050 [username]@[remote.server.name]

To refresh your memory, here is an extract from the ’ssh’ manual page for the -D option:

-D [bind_address:]port
Specifies a local “dynamic” application-level port forwarding. This works by allocating a socket to listen to port on the local side, optionally bound to the specified bind_address. Whenever a connection is made to this port, the connection is forwarded over the secure channel, and the application protocol is then used to determine where to connect to from the remote machine. Currently the SOCKS4 and SOCKS5 protocols are supported, and ssh will act as a SOCKS server. Only root can forward privileged ports. Dynamic port forwardings can also be specified in the configuration file.

Using the SOCKS proxy

MacOSX 10.5 Proxy screen

Next you need to tell the applications to use the SOCKS proxy. If you are still using a Mac when you are reading this, you’ll probably have it pretty easy. Mac OSX lets you set a proxy system-wide that all well-written Mac applications will use to get their parameters. It is in the “Proxies” tab of the Advanced… network settings. On Mac OSX version 10.5 (Leopard), it looks like the graphic to the right.

If you’re using some sort of UNIX variant, the application may have a setting to use a SOCKS client, or you may need to use the ‘tsocksshim that intercepts the network calls of the application. And, future self, if you are using a Microsoft Windows box right now, please remember how much simpler life was when you used a Mac or Linux desktop. If you find yourself in such a spot, some reader of this blog posting may have left a comment for you below that will help you use a SOCKS proxy with a Windows platform.

Hope this helps. Sincerely,

Self, circa February 2008

Footnotes

  1. Version of the “Proxy Server” Wikipedia page when this posting was written []
  2. Version of the SOCKS Wikipedia page when this posting was written []

4 Comments

  1. tonsofpcs | June 19, 2008 at 4:11 pm | Permalink

    In Windows, you can set the forward up with PuTTY (”Dynamic Port Forwarding”) and you can traverse the “SOCKS” proxy by settings in individual applications.

  2. the Jester | June 19, 2008 at 10:10 pm | Permalink

    @tonsofpcs : Thanks for the reply. PuTTY looks like a free telnet/ssh client for windows — the equivalent of opening up a terminal session and running the command line ssh program in the directions above. I was sort of hoping that there would be a system-wide SOCKS setting that could be made that well-behaving applications would use (as opposed to having to set the SOCKS proxy in each individual one). Perhaps that isn’t the case with Windows.

  3. jon | July 18, 2008 at 5:05 pm | Permalink

    helped me. :)

    ssh -D + firefox plugin foxyproxy works like a charm here.

  4. the Jester | July 21, 2008 at 9:59 pm | Permalink

    I use FoxyProxy as well, Jon, and agree that it makes the Firefox setup very easy. (Firefox is one of those Mac programs that doesn’t read the standard network parameters, such as the SOCKS proxy, out of the operating system configuration.)

6 Trackbacks

  1. PALINET Tech Update - PLN | February 22, 2008 at 1:32 pm | Permalink

    Kramer auto Pingback[...] Selected technology-related posts from a variety of library blogs DVD Wars Over 18 February 2008 Note to Future Self: Use `ssh -D` to bypass annoying interception … 18 February 2008 A new partnership for OpenTranslators 18 February 2008 U.S. eBook sales up 23.6% [...]

  2. SonicWALL still hates us - Hack a Day | June 18, 2008 at 9:25 pm | Permalink

    Kramer auto Pingback[...] any trouble viewing Hack a Day from your school/work? What “service” are they using? We use ssh’s application level dynamic port forwarding to get around most systems when we’re on the road.PermalinkEmail thisLinking BlogsComments [...]

  3. Kramer auto Pingback[...] any trouble viewing Hack a Day from your school/work? What “service” are they using? We use ssh’s application level dynamic port forwarding to get around most systems when we’re on the road.Permalink

  4. Frayed Knots | June 20, 2008 at 3:01 am | Permalink

    Kramer auto Pingback[...] any trouble viewing Hack a Day from your school/work? What “service” are they using? We use ssh’s application level dynamic port forwarding to get around most systems when we’re on the road.Permalink | Email [...]

  5. Foo - Techdocs | June 23, 2008 at 7:56 pm | Permalink

    Kramer auto Pingback[...] [edit] ssh tunneling [edit] names violet dante leeloo faye Retrieved from [...]

  6. Bookmarks 2008-06-24 | June 25, 2008 at 6:27 am | Permalink

    Kramer auto Pingback[...] (ACL) sous Linux à partir de Nautilus. (Tags: linux ubuntu system security opensource software) Note to Future Self: Use `ssh -D` to bypass annoying interception proxies | Disruptive Library Techn… - http://dltj.org/article/ssh-as-socks-proxy/C‘est tellement simple d’utiliser un client ssh comme [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *
Human Detection Scheme
(What's this?)
Comment Preview

Subscribe without commenting

From the Disruptive Library Technology Jester (http://dltj.org/), printed on Saturday the 30th of August 2008 at 12:53:48 AM EDT (-0400). The URL to this page is http://dltj.org/article/ssh-as-socks-proxy/

[Creative Commons Logo] This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/us/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.