Skip to content

Instantly share code, notes, and snippets.

@SCP002
Last active January 4, 2026 16:55
Show Gist options
  • Select an option

  • Save SCP002/58cf405c7eaab0830de5daa4f4495988 to your computer and use it in GitHub Desktop.

Select an option

Save SCP002/58cf405c7eaab0830de5daa4f4495988 to your computer and use it in GitHub Desktop.
SSH: Tunnel all traffic using dynamic port

On client, run:

ssh -f -N -D 1080 -p 22 USER@REMOTE_ADDR

replace:

1080 - with port to open local SOCKS server at (if already taken).

22 - with SSH port server is listening to (if using non-default).

USER - with your login.

REMOTE_ADDR - with address of remote machine.

and enter your password.

You can now close the terminal.

To stop it, kill the SSH process or run without -f flag and press Ctrl+C.

Then, on client, either:

A) Open a browser, find proxy settings and specify "SOCKS": address 127.0.0.1, port 1080.

B) Set system proxy to these values, but it will not work on Windows since Windows proxy settings does not support SOCKS. On Windows, better use third-party software for it.

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