If you can log in to a server with SSH, you already have an SSH proxy. Run ssh -D 1080 user@server and your computer gets a SOCKS5 proxy on port 1080 that leaves from the server’s IP address. It is free, encrypted and takes one minute. The limit is that you get one address, usually in a data center, so for many locations or home IPs you need residential proxies instead.
The command
ssh -N -D 127.0.0.1:1080 user@your-server
-Dstarts the SOCKS proxy on your own computer.127.0.0.1makes sure only your computer can use it. Leave it in.-Nmeans “do not open a shell, just keep the tunnel”.
The window stays open while the tunnel runs. Press Ctrl+C to close it. To run it in the background, add -f.
Windows 10 and 11 include the same ssh command in PowerShell. On macOS and Linux it is there by default.
To tunnel SSH traffic through another machine on the way, add a jump host with -J user@gateway.
Check that it works
In a second window:
curl -x socks5h://127.0.0.1:1080 https://api.ipify.org
The address it prints should be your server’s. We ran this with OpenSSH 9.9: a plain request showed our own address, and the same request through the tunnel showed the server’s. A page from cloudflare.com loaded over HTTP/2.
Keep the h in socks5h. It tells curl to let the server look up the website’s name. With plain socks5, your computer does the lookup and your own DNS provider sees which sites you visit.
Use it in a browser
Firefox has its own proxy settings. Choose manual configuration, enter 127.0.0.1 and port 1080 as the SOCKS host, pick SOCKS v5, and tick the option to proxy DNS when using SOCKS v5.
Chrome follows the system settings, but you can start a separate window with its own profile:
google-chrome --user-data-dir=/tmp/tunnel --proxy-server="socks5://127.0.0.1:1080"
On macOS, use the full path to the Chrome app. If you switch often, an extension is easier. Our FoxyProxy guide shows how to set up profiles.
Make it permanent
Add the server to ~/.ssh/config:
Host tunnel
HostName your-server
User user
DynamicForward 127.0.0.1:1080
ServerAliveInterval 30
Now ssh -N tunnel is enough. ServerAliveInterval sends a small message every 30 seconds, which keeps idle connections from being dropped and lets SSH notice when the link is dead.
ssh -D or sshuttle
ssh -D only covers apps that support SOCKS. sshuttle covers the whole device:
sshuttle -r user@your-server 0/0 --dns
| ssh -D | sshuttle | |
|---|---|---|
| Covers | Apps you set to use it | The whole device |
| Root on your computer | No | Yes |
| Needs on the server | SSH login | SSH login and Python |
| DNS | With socks5h or a browser option | With --dns |
| Windows | Built in | Experimental |
sshuttle’s documentation asks for Python 3.10 or newer on both sides. We did not run it for this guide; the command above follows its documentation.
When it is the wrong tool
- You need several countries. One server gives you one location.
- Sites block hosting addresses. A website can see that the IP belongs to a hosting company, and some treat those differently.
- You need UDP. The SOCKS proxy made by
ssh -Dcarries TCP only. - Many people share it. Everyone’s traffic leaves from one address, and the server’s logs tie it to an account.
Keep it safe
Use SSH keys instead of passwords. Never bind the proxy to 0.0.0.0: that opens it to anyone who can reach your computer, and open proxies get found and abused quickly. Only tunnel through servers you own or have permission to use, because your traffic will appear under the owner’s name. If the proxy stops answering, our guide to 407 proxy errors helps you tell a login problem from a connection problem.