Skip to content

Instantly share code, notes, and snippets.

@ntamvl
Last active February 21, 2024 11:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ntamvl/67f6fd6b56d5a200e0526c79eed548e6 to your computer and use it in GitHub Desktop.
Save ntamvl/67f6fd6b56d5a200e0526c79eed548e6 to your computer and use it in GitHub Desktop.
SOCKS 5 proxy tunnel

SOCKS 5 proxy tunnel

Open a terminal program on your computer. On Mac OS X, this is Terminal in Applications > Utilities.

Set up the tunnel with this command:

ssh -D 8123 -f -C -q -N ubuntu@example.com

Explanation of arguments

-D: Tells SSH that we want a SOCKS tunnel on the specified port number (you can choose a number between 1025-65536)
-f: Forks the process to the background
-C: Compresses the data before sending it
-q: Uses quiet mode
-N: Tells SSH that no command will be sent once the tunnel is up

Be sure to replace ubuntu@example.com with your own sudo user and server IP address or domain name.

Once you enter the command, you'll immediately be brought to the command prompt again with no sign of success or failure; that's normal.

Verify that the tunnel is up and running with this command:

ps aux | grep ssh

You should see a line in the output like: Output

ubuntu    14345   0.0  0.0  2462228    452   ??  Ss    6:43AM   0:00.00 ssh -D 8123 -f -C -q -N ubuntu@example.com

You can quit your terminal application and the tunnel will stay up. That is because we used the -f argument which put the SSH session into the background.

Note: If you want to terminate the tunnel you'll have to grab the PID via ps and use the kill command, which we'll show you how to do later.

source: https://www.digitalocean.com/community/tutorials/how-to-route-web-traffic-securely-without-a-vpn-using-a-socks-tunnel

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