SOCKS proxy with SSH


That’s not a new thing, but I happened to use it during the weekend to be able to access some services back in Brazil that were IP-limited and HideMyAss couldn’t help, so I asked a friend for a small proxy help.

What I did on my side:

  1. Opened a port on my modem to forward the connection to the port 51000 on my computer;
  2. Started a container: docker run -p 51000:51000 -p 51001:51001 --rm -it ubuntu:xenial bash;
  3. Installed supervisord, openssh-server and added GatewayPorts yes to /etc/ssh/sshd_config;

My friend had to run those commands in parallel:

  1. ssh -D 51001 localhost;
  2. ssh -R :51001:localhost:51001 use@myIP -p 51000;

And voilá, I had a SOCKS proxy over localhost:51000 that was going out to the internet using a Brazilian IP address.