Using an SSH server as a SOCKS proxy

2nd October 2013 (11 years ago)

SSH has support for SOCKS built in. If you have a remote SSH server you can use it as a proxy for web and other traffic.

Connect to the server with the following command and after a few seconds you will have a SOCKS proxy at 127.0.0.1 port 8080.

ssh -C2qTnN -D 8080 <user@remotehost>

The options set Compression, SSH2 only, Quiet, Force pseudo-tty allocation, Redirect stdin from /dev/null, and Place the ssh client into "master" mode for connection sharing.

In Firefox go to Preferences > Advanced > Network > Settings...

Choose the Manual proxy configuration option and on the SOCKS Host line add 127.0.0.1 and 8080. Leave HTTP Proxy and the others blank. SOCKS v5 is the preferred version.

In about:config in Firefox it's best to set network.proxy.socks_remote_dns to true so that DNS queries also go via the SSH connection.

You can also configure this system-wide depending on your platform.