All locations active · 99.99% uptime
SOCKS5

Setting Up a SOCKS5 Tunnel over SSH

If you have SSH access to a server, you can run your own SOCKS5 proxy without installing any extra software. SSH's dynamic port forwarding feature does exactly that: it opens a SOCKS5 listener on your local machine and carries all traffic to your server over an encrypted SSH tunnel.

The Basic Command

FIGUREDynamic port forwarding
Terminal01# Open a SOCKS5 listener on local port 108002ssh -D 1080 -q -C -N kullanici@sunucu.example.com0304# -D 1080 local SOCKS5 listening port05# -q quiet mode06# -C compression (useful on slow connections)07# -N no remote command execution, tunnel only0809# Allow access from the local machine only (the secure default)10ssh -D 127.0.0.1:1080 -q -C -N kullanici@sunucu.example.com1112# Run it in the background13ssh -f -D 1080 -q -C -N kullanici@sunucu.example.com1415# Usage16curl --socks5-hostname 127.0.0.1:1080 https://ornek-ip.example/text

-D 127.0.0.1:1080 guarantees that the listener is reachable only from the local machine. Leaving it open to the network is a serious security risk.

The Traffic Path

FIGUREThe layers of an SSH SOCKS5 tunnel
TUNNELTCP connectionSSH encryptionThe SOCKS5 protocolApplication trafficLocal machine → server(port 22)The whole tunnel, end to endencrypted tooThe local 1080 listenerBrowser, curl,any tool you likeThe address the target sees: your server's IP

The SSH tunnel closes SOCKS5's encryption gap: credentials and traffic are protected at the SSH layer.

Advantages

Strengths

  • No extra software required; SSH is everywhere.
  • The tunnel is encrypted end to end.
  • Your server's IP is static — close to ISP proxy behaviour.
  • You have full control; you set the logging policy.
  • The only cost is the server rental.

Limits

  • A single IP — no pool and no rotation.
  • Your server is usually in a datacenter; ASN it appears as hosting.
  • It does not carry UDP (SSH dynamic forwarding is TCP only).
  • It does not work on networks where port 22 is blocked.
  • If the connection drops, the tunnel closes.
Managing expectations

An SSH tunnel exits from a datacenter IP. That means on strictly protected platforms it is subject to the same limits as datacenter proxy . If your goal is to establish a secure channel, it is perfect; if it is to raise your trust score, it is not the right tool.

A Permanent, Resilient Tunnel

To have the tunnel re-established automatically when the connection drops, autossh can be used:

FIGUREA permanent tunnel that survives drops
autossh + systemd01# Automatic reconnection with autossh02autossh -M 0 -f -N -D 127.0.0.1:1080 \\03 -o "ServerAliveInterval 30" \\04 -o "ServerAliveCountMax 3" \\05 -o "ExitOnForwardFailure yes" \\06 kullanici@sunucu.example.com0708# systemd service file (/etc/systemd/system/socks-tunnel.service)09[Unit]10Description=SSH SOCKS5 tunnel11After=network-online.target1213[Service]14User=kullanici15ExecStart=/usr/bin/autossh -M 0 -N -D 127.0.0.1:1080 kullanici@sunucu.example.com16Restart=always17RestartSec=101819[Install]20WantedBy=multi-user.target

ServerAliveInterval setting makes it possible to detect silent drops. Without it, the tunnel may "look open" while not actually working.

Use on Windows

Windows 10 and later include the OpenSSH client built in; the same command works in PowerShell. Then, in your browser or application settings, 127.0.0.1:1080 is entered as SOCKS5. For Windows proxy settings, see Windows 11 proxy settings article.

Security Checklist

FIGURESSH tunnel security checks
SECURITYThe listener on 127.0.0.1 onlyDo not leave it open to the networkKey-based authenticationUse an SSH key instead of a passwordDo not connect as root on the serverA user with limited privileges is enoughServer security updatesApply patches regularlyResolve DNS remotelysocks5h or the browser settingMonitor the tunnel statusCatch silent drops

Opening the listener on 0.0.0.0 means that anyone on the same network can use your proxy. That is a serious abuse risk.

When an SSH Tunnel, When a Commercial Proxy?

FIGUREWhich one is right for you?
DECISIONWhat is your core need?A secure channel and a single static IPYESAn SSH tunnel is idealNOSee belowFree and fully under your controlGeographic variety and rotationYESCommercial proxyNOSee belowYou need a poolA high trust scoreYESResidential / ISPNOSSH tunnelA hosting ASN is not enough

The two are not alternatives to each other; they answer different needs. Many developers use both together.

Summary

SSH dynamic port forwarding gives you an encrypted, fully controlled SOCKS5 proxy with a single command. It exits from your server's static IP, requires no extra software and carries no risk of credential leakage. On the other hand, it offers no pool, no rotation and no UDP support; because of the hosting ASN it falls short on strictly protected platforms. If you want to establish a secure channel, it is the most practical method. For commercial alternatives, see SOCKS5 proxy and ISP proxy pages.

Frequently Asked Questions

01Is an SSH tunnel a real SOCKS5 proxy?

Yes. The SSH client opens a standard SOCKS5 listener on your local machine; any application that supports SOCKS5 can use it.

02Does an SSH tunnel carry UDP?

No. SSH dynamic port forwarding supports TCP connections only. Scenarios that require UDP need a different solution.

03My tunnel keeps dropping — how do I make it permanent?

Use autossh and tune the ServerAliveInterval and ServerAliveCountMax options. For permanent operation, defining it as a systemd service is the most robust method.

04Does an SSH tunnel make me more anonymous?

It hides your traffic from the local network and encrypts it; however, the target site sees your server's IP. If your server is in a datacenter, it is classified as a hosting ASN.

05Can I open the listener to the network?

Technically possible, but not recommended. An open SOCKS5 listener with no authentication can be used by anyone on the same network and creates a serious abuse risk.

Related Articles and Pages

NEXT STEP

Strengthen your proxy setup today.

Get started in minutes with a paid plan, or try our free proxy list first.

FREEPROXY.TR

Looking for a free proxy? You're in the right place

A complete proxy platform where you can browse up-to-date free proxy addresses, compare HTTP and SOCKS proxy types, and check your proxy connections with free tools.