OSX SSH Tunnel Automation

tl;dr

I frequently travel and im fairly paraniod. These two things are in deep conflict when I'm say...in a hotel, or using airport WIFI. Because of this I often increase my comfort by pairing a dynamic SSH tunnel with a local SOCKS proxy.

There are plenty of articles that explain how the tunnel itself works, so I won't bother doing it again here.

First off you will need to create network locations for your proxy and non-proxy configurations. I have named mine 'Home' and 'Proxy'. Then configure the proxy settings for the Proxy location. Choose a SOCKS Proxy with 'Streaming Proxy Server' "localhost:8888".

Once you have the locations setup you need to create an SSH tunnel...easy enough with ssh -C -D 8888 user@example.com. Any unused port can be set here, I just like 8888.

After you have opened the tunnel and set your location to 'Proxy', head on over to ipchicken and you should see your remote server's IP.

Now thats all well and such but I am pretty lazy. This is far more steps than I can reasonably justifiy for the activities of connecting to, or disconnecting from a proxy. So I setup a q/d bash script to handle the connection and location switching for me. It is still necessary to do the initial location configuration, but after that the script does the rest.

The comments should explain all the necessaries. There is a lot that could be done to make this more functional, and much more pretty. Feel free to do so as your use case/tastes require.

-Phil

by Phil Jackson

Loading Google+ Comments ...