Simple SOCKS proxy using SSH

Sometimes we find ourselves in places where we don't trust the network that we're using. I've found myself in quite a few situations where I know my data is being encrypted, but I want an additional layer of protection. Luckily, that protection is built into SSH if you'd like to use it.

Create a simple SOCKS proxy with SSH by using the -D flag:

ssh -D 2400 username@some.host.com

That command will open up a SOCKS proxy on your workstation on port 2400. If you configure your application to use the local SOCKS proxy, any traffic using the proxy will be sent through an encrypted SSH connection to your remote server and out to the internet. Inbound traffic through the proxy is encrypted through the same connection.

You can pair that with autossh to keep your proxy connected at all times:

autossh -f -M 20000 -D 2400 username@some.host.com -N
Printed from: http://rackerhacker.com/2009/05/26/simple-socks-proxy-using-ssh/ .
© Major Hayden 2012.

2 Comments   »

  • Andrew Young says:

    Awesome tip! I love ssh, it's one of the simplest and most useful tools out there. :)

  • Ace says:

    Thank you, I was looking for something like this.

RSS feed for comments on this post

Leave a Reply

 

  • Welcome! I started this blog as a way to give back to all of the other system administrators who have taught me something in the past. Writing these posts brings me a lot of enjoyment and I hope you find the information useful. If you spot something that's incorrect or confusing, please write a comment and let me know. Drop me a line if there's something you want to know more about and I'll do my best to write a post on the topic.
    -- Major Hayden

    Flattr this