SOCKS Proxy through SSH Tunneling

Objective:

Connect to internet via SOCKS proxy through another machine. It is particlarly useful when:

  • The machine you are working on does not allow internet access, but does allow ssh to other machines (which are connected to internet).
  • You want to add an extra layer of security and privacy.

Method

Create a SOCKS proxy thourhg ssh tunneling.

ssh -D LOCAL_PROXY_PORT -N -f SSH_SERVER
  • -D: Specifies a local ``dynamic'' application-level port forwarding.
  • -N: Do not execute a remote command.
  • -f: Requests ssh to go to background.

Run a program thorugh a proxy server using proxychains. Install proxychains and add the following to the end of ~/.proxychains/proxychains.conf.

socks5 127.0.0.1 LOCAL_PROXY_PORT
  • LOCAL_PROXY_PORT corresponds to the one that you specified in the ssh command.

Example uses:

proxychains wget http://some-website
proxychains git clone https://github.com/som-repository

blogroll

social