Monday 13 December 2010

using a remote machine as a proxy with SSH

This is such a useful feature of SSH that I wish I had know about before now.

When working remotely from an insecure location, or when only the remote location is trusted by another host, e.g for a firewall login or viewing intranet pages you only have access to from a certain machine; you can use a remote machine as a SOCKS proxy straight out of the box.

e.g. on the localmachine, run:

ssh -fND 1234 username@yourremotemachine

This will create a SOCKS proxy on localhost port 1234
-f flag tells the shell to fork and run in the background
-N Leaves no login shell
-D 1234 sets up a SOCKS proxy via port 1234 on the localhost

On the local machine you can then set the browser to use the SOCKS 5 proxy on localhost port 1234