How to create a socks proxy tunnel with ssh

If you’re in a network which is insecure and you can not use any VPN methods but you have a remote ssh access, it is possible to create a SOCKS5 proxy tunnel with ssh.

No special client needed to create socks tunnel over ssh, just use following command:

$ ssh -D 1080 -N user@server
  • -D option used to select listening port. It must be > 1023 to bind as a normal user. 1080 is default port for normal socks server, you can use anything you want as port number
  • -N option tells ssh that we don’t send any command once the tunnel setup completed

You can also use following extra parameters:

  • -C option activates ssh compression feature on tunnel
  • -f option forks the process and tunnel create command runs in background
  • -q option used for running in quiet mode

After tunnel setup completed, you need to change proxy settings of clients. In Linux, most of the clients takes proxy settings from network-manager. You can change proxy settings like that:

Now you can use your browser for safe surfing.