Skip to content

Instantly share code, notes, and snippets.

@jdmichaud
Created December 8, 2019 15:19
Show Gist options
  • Save jdmichaud/203dbe0b3b166d27ca73e8db3786a6c0 to your computer and use it in GitHub Desktop.
Save jdmichaud/203dbe0b3b166d27ca73e8db3786a6c0 to your computer and use it in GitHub Desktop.
VPN over SSH

Info from https://sanctum.geek.nz/arabesque/ssh-socks-and-curl/

Server

You need a server with ssh configured. Pay attention to /etc/ssh/sshd_config:

#Port 22

This will be commented by default, so you can't access your ssh server from the outside. Uncomment it.

#Port 1234

Make sure that this also is uncommented:

AllowTcpForwarding yes

Client

Start a ssh client:

ssh -ND localhost:8001 jd@localhost -p 1234
  • -N to prevent a shell to start. We don't need one.
  • -D to start a dynamic port forwarding proxy server locally on the indicated port (here 8001).
  • -p 1234 This is the port where the server is listening.

Test

With curl:

curl --proxy socks5h://localhost:8001 https://text.npr.org/

the h in socks5h means that even DNS requests are forwaded.

To condigure Firefox, put localhost in SOCKS hostname and 8001 in port. Make sure you tick Proxy DNS when using SOCKS5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment