Skip to content

Instantly share code, notes, and snippets.

@carlosh93
Last active January 26, 2021 14:07
Show Gist options
  • Save carlosh93/a9d96fee642be4631121caf2b20db5fd to your computer and use it in GitHub Desktop.
Save carlosh93/a9d96fee642be4631121caf2b20db5fd to your computer and use it in GitHub Desktop.
VPN over SSH
# You can create ssh connection with dynamic port forwarding to create socks proxy:
ssh -D 9050 user@sshserver -fTNC
# -D [bind_address:]port Specifies a local “dynamic” application-level port forwarding... Whenever a connection is made to this port, the connection is forwarded over the secure channel, and the application protocol is then used to determine where to connect to from the remote machine. Currently the SOCKS4 and SOCKS5 protocols are supported
# The options -fTNC will enable the compression and will push the connection in the background.
# Optionally use autossh instead of ssh
# In addition, you can create crontab entry as this
# @reboot autossh -D 9050 user@sshserver -fTNC
# The rest you need to do is to tell your applications to use localhost:9050 as socks proxy. Install SOCKS proxy extension in Chrome
# sudo apt install sshpass
sshpass -p carloshinojosa12 ssh -D 9050 [email protected] -fTNC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment