How to set up a local SOCKS proxy that tunnels traffic through SSH

ssh -D 1337 -f -C -q -N user@remote -p 22
  • -D 1337 tells ssh to launch a SOCKS server on port 1337 locally.
  • -f forks the process into the background.
  • -C Turns on compression.
  • -q enables “Quiet mode”, since the purpose here is only to tunnel we don’t really care about error output and such.
  • -N tells ssh that no commands will be sent (-f complains if we don’t specify this).
  • -p specifies what port to use; obviously this is defaulted to 22 so the statement above is pointless, but if you’re a clever fellow you’re probably not running SSH on port 22 πŸ™‚

References :
http://askubuntu.com/questions/469582/how-do-i-set-up-a-local-socks-proxy-that-tunnels-traffic-through-ssh