2011/05/16

Quick Encrypt your coffee shop traffic using an ssh tunnel

Just a little function to add to your Apple OS's .profile that automatically turns on a socks proxy and tunnels all your traffic through the server of your choice. It's a simple setup and <CTRL>+C kills the connection and shuts off the proxy. This assumes that you have shell access to some server that you trust to run your traffic through. I recommend setting up public key authentication for ease of use.
# warm feet
function socks() {
    networksetup -setsocksfirewallproxy AirPort localhost 9999
    ssh -ND 9999 -C username@domain
    networksetup -setsocksfirewallproxystate AirPort off
}
One caveat: If you happen to close the window of your terminal without hitting <CTRL>+C first, it will not disable the socks proxy.