Integrations menu
Developer guide

SSH with a SOCKS Proxy

To connect over SSH through a SOCKS proxy, give ssh a ProxyCommand that opens the connection through the proxy: ssh -o ProxyCommand="nc -X 5 -x PROXY_HOST:PROXY_PORT %h %p" user@server, or with a proxy username and password, ncat --proxy PROXY_HOST:PROXY_PORT --proxy-type socks5 --proxy-auth PROXY_USER:PROXY_PASS %h %p as the ProxyCommand. To turn an SSH server into a SOCKS proxy instead, run ssh -D 1080 -N user@server. ProxyField sells residential proxies over SOCKS5, HTTP and HTTPS from $1.95/GB ($2.95/GB for 1 GB), with a 99.6% success rate, according to our service data; ask our 24/7 live chat whether the gateway carries SSH before you buy for it, and start with the Easy Trial: 1 GB for $2.95, no subscription, and the traffic never expires.

residential IPs
412M+
from, traffic never expires
$1.95/GB
Easy Trial
1 GB for $2.95
gate.proxyfield.io:7000
ProxyField details for SSH
SSH settingProxyField value
ncat --proxy, PuTTY Proxy hostname and Portgate.proxyfield.io, port 7000; SOCKS5, HTTP and HTTPS all run on the same host and port
--proxy-type, PuTTY Proxy typesocks5 in ncat, SOCKS 5 in PuTTY; http also works (it opens the connection with CONNECT)
Username (--proxy-auth, PuTTY Username)<login>-country-us-city-new_york; the optional keys are -country-<cc>, -region-<region>, -city-<city>, -session-<id> and -ttl-<seconds> (30 to 129,600 s, 20 min when ttl is left out); add -mobile or -dc right after the login for mobile or rotating datacenter IPs (-dc takes the country only)
Passwordyour ProxyField password
SOCKS5the same username and password; where a tool asks for a proxy URL, write socks5h:// so the gateway resolves the server's name
nc -X 5 (sends no SOCKS5 login)your IP on the allowlist (up to 100 IPv4 addresses) and the port you set up in the dashboard
SSH on the gatewaySSH uses port 22 rather than a web port: ask our 24/7 live chat whether the gateway carries SSH before you buy for it
IP behavioura new IP on every request, or one IP for 30 s to 36 h with -session-<id>-ttl-<seconds>; for SSH, a request is a new connection
Headersthe gateway adds no Via, X-Forwarded-For or Forwarded header; the headers your client sends pass through; your Proxy-Authorization is removed before the request goes to the site

Set up SSH with ProxyField

  1. Ask our 24/7 live chat whether the gateway carries SSH to your server.
  2. Install Nmap's ncat (on Windows from the Nmap installer, on a Mac with Homebrew's nmap package).
  3. Add a ProxyCommand with ncat --proxy-type socks5 and your login to the server's Host block in ~/.ssh/config, or pass it with -o.
  4. In PuTTY instead: Connection → Proxy, SOCKS 5, gate.proxyfield.io, port 7000, your username and password.
  5. Connect with ssh -v to see each step, including the ProxyCommand it runs.

The ncat ProxyCommand with ProxyField's values, once our live chat has confirmed SSH for your server.

Shell
ssh -o ProxyCommand="ncat --proxy gate.proxyfield.io:7000 --proxy-type socks5 --proxy-auth <login>-country-us-city-new_york:<password> %h %p" [email protected]

OpenSSH's own reference for ProxyCommand: ssh_config(5) (OpenBSD manual pages).

"SSH with a SOCKS proxy" means one of two setups, and this page covers both:

You wantCommandWho provides the SOCKS proxy
Your SSH connection to reach the server from another IPssh with a ProxyCommanda SOCKS5 proxy service
A SOCKS proxy that exits from your own serverssh -D 1080your SSH server

The commands below work with any SOCKS5 proxy: PROXY_HOST and PROXY_PORT stand for its address and port, PROXY_USER and PROXY_PASS for its login.

On this page 9 sections

1. SSH through a SOCKS5 proxy with ProxyCommand

ssh has no proxy option of its own. It runs the command in ProxyCommand, which opens the connection through the proxy and hands it to ssh; %h and %p stand for the server and port.

With your IP on the allowlist (no proxy login), the netcat that ships with macOS and most Linux systems is enough:

Shell
ssh -o ProxyCommand="nc -X 5 -x PROXY_HOST:PROXY_PORT %h %p" [email protected]

-X 5 selects SOCKS5 and -x names the proxy. This netcat sends a proxy login (-P user, with the password prompted) only to HTTP proxies (-X connect), not to SOCKS5 proxies, so for SOCKS5 it needs your IP on the proxy's allowlist.

With a username and password, use Nmap's ncat:

Shell
ssh -o ProxyCommand="ncat --proxy PROXY_HOST:PROXY_PORT --proxy-type socks5 --proxy-auth PROXY_USER:PROXY_PASS %h %p" [email protected]

The same command with --proxy-type http goes through the HTTP proxy instead (it opens the connection with CONNECT), which works when SOCKS5 isn't an option.

2. Keep it in ~/.ssh/config

Write the proxy once per host instead of on every command:

Host myserver
    HostName server.example.com
    User me
    ProxyCommand nc -X 5 -x PROXY_HOST:PROXY_PORT %h %p

Then ssh myserver, scp file myserver: and sftp myserver all go through the proxy, and other hosts connect directly. Prefer the allowlist here: a password in a ProxyCommand line sits in plain text in the file. If you must use one, keep the file readable only by you (chmod 600 ~/.ssh/config).

3. Windows: OpenSSH and PuTTY

OpenSSH on Windows 10 and 11 reads the same ProxyCommand. Windows has no nc, so use ncat from the Nmap installer, or connect.exe, which comes with Git for Windows:

Host myserver
    HostName server.example.com
    ProxyCommand "C:\Program Files\Git\mingw64\bin\connect.exe" -S PROXY_USER@PROXY_HOST:PROXY_PORT %h %p

connect reads the proxy password from the SOCKS5_PASSWORD environment variable; -H instead of -S uses the HTTP proxy.

PuTTY has the proxy built in:

  1. Open Connection → Proxy.
  2. Set Proxy type to SOCKS 5, and enter the proxy's address in Proxy hostname and its port in Port.
  3. Enter the proxy's Username and Password.
  4. Go back to Session, enter your server, save the session and select Open.
    Screenshot PuTTY Connection Proxy settings with SOCKS 5, a proxy hostname and port

4. Git over SSH through the proxy

Git uses ssh for git@ remotes, so a Host block in ~/.ssh/config covers git clone, pull and push:

Host github.com
    ProxyCommand nc -X 5 -x PROXY_HOST:PROXY_PORT %h %p

For one command only, set GIT_SSH_COMMAND='ssh -o ProxyCommand="nc -X 5 -x PROXY_HOST:PROXY_PORT %h %p"' before it. HTTPS remotes use the HTTP proxy instead (git config --global http.proxy http://<login>:<password>@gate.proxyfield.io:7000); see Linux for setting it system-wide.

5. One IP for the whole session

An SSH session is one long TCP connection, and a TCP connection through a proxy keeps one exit IP for its whole life. Rotation matters between connections: on a rotating proxy, each new ssh, scp or git command may leave from a different IP. If the server only accepts known IPs, or you don't want it to see a new address every time:

  • use a sticky session in the username, which keeps one IP for 30 s to 36 h;
  • or a dedicated ISP proxy, one IP for 30 days: from $2.29 per IP (static residential (ISP) proxies).

6. Make your own SOCKS proxy with ssh -D

ssh -D turns an SSH connection into a SOCKS proxy on your computer, and the traffic exits from the SSH server:

Shell
ssh -D 1080 -N -C [email protected]
curl --socks5-hostname 127.0.0.1:1080 https://api.ipify.org   # prints the server's IP

-D 1080 opens the SOCKS proxy on 127.0.0.1:1080, -N runs no remote command and -C compresses. Point a browser or app at 127.0.0.1:1080 as a SOCKS5 proxy with "proxy DNS" on, and it browses from the server's IP. This gives you one IP, the server's, in the server's country. ProxyField is the other way round: 412M+ residential IPs in 195+ countries, without a server to run.

ssh -R 1080 user@server (OpenSSH 7.6 or later) is the reverse: it opens a SOCKS proxy on the server whose traffic exits from your computer.

Check and fix

SymptomLikely causeFix
nc: connection failed, SOCKSv5 errorNo login with nc, and your IP is not on the allowlistAdd your IP to the allowlist, or use ncat with --proxy-auth
kex_exchange_identification: Connection closedThe proxy closed the connection to port 22Check that the proxy carries SSH (see the port note above); try the HTTP proxy type
ssh: Could not resolve hostnameA typo in HostNameThe server name goes in HostName; the proxy only in ProxyCommand
Works once, then the server refuses youThe server sees a new IP per connectionUse a sticky session or a dedicated ISP IP
TimeoutsA firewall blocks the outgoing proxy portAllow port 7000, or the port you set up in the dashboard for the allowlist

ssh -v shows each step, including the ProxyCommand it runs. To check your ProxyField login itself, run curl -x http://<login>:<password>@gate.proxyfield.io:7000 https://api.ipify.org or use the proxy checker; more commands are on cURL. Gateway error messages: 407 Proxy Authentication Required for a wrong login or password, an IP not on the allowlist or a malformed location, 402 Payment Required when no traffic is left and 502 Bad Gateway when no exit could be connected; a restricted site gets no separate response, and a 403 comes from the site itself. Our 24/7 live chat helps with setup and integration.

Connect only to servers you are allowed to use. Scanning, password guessing and attacks on systems are not allowed under our acceptable use policy, and some site categories are restricted to protect the network, including financial and government services.

Get started

Start with the Easy Trial: 1 GB for $2.95, with no minimum purchase and no subscription. The traffic never expires and all purchases are final. See pricing per GB and SOCKS5 proxies.

SSH with a SOCKS Proxy FAQ

How do I use SSH with a SOCKS proxy?

ProxyField sells SOCKS5, HTTP and HTTPS proxies from $1.95/GB ($2.95 for 1 GB); SSH reaches a server through a SOCKS5 proxy with -o ProxyCommand="nc -X 5 -x PROXY_HOST:PROXY_PORT %h %p" and your IP on the proxy's allowlist, or with ncat --proxy-type socks5 --proxy-auth as the ProxyCommand when the proxy needs a login. The SSH server then sees the proxy's IP instead of yours. Ask our 24/7 live chat whether the ProxyField gateway carries SSH before you buy for it.

How do I set ProxyCommand for a SOCKS5 proxy in SSH?

In ~/.ssh/config, under the server's Host block, add ProxyCommand nc -X 5 -x proxyhost:port %h %p. Use ncat --proxy-type socks5 --proxy-auth user:pass instead of nc when the proxy needs a login.

Does nc support SOCKS5 with a username and password?

No. The OpenBSD netcat on macOS and most Linux systems sends a proxy login (-P) only to HTTP CONNECT proxies, not to SOCKS5 ones. For SOCKS5, put your IP on the proxy's allowlist, or use Nmap's ncat with --proxy-auth, or connect with the SOCKS5_PASSWORD variable.

How do I use SSH as a SOCKS proxy?

Run ssh -D 1080 -N user@server, then set 127.0.0.1:1080 as a SOCKS5 proxy in your browser or app. Traffic then exits from the SSH server, with the server's IP.

What is the difference between ssh -D and connecting SSH through a proxy?

ssh -D makes a SOCKS proxy whose traffic exits from your SSH server. ProxyCommand does the opposite: your SSH connection itself goes out through another proxy, so the server sees that proxy's IP.

How do I use a SOCKS proxy with SSH on Windows?

OpenSSH on Windows reads ProxyCommand; use ncat from Nmap or connect.exe from Git for Windows as the command. PuTTY has the setting built in under Connection → Proxy.

How do I set a SOCKS proxy in PuTTY?

Open Connection → Proxy, choose SOCKS 5, enter the proxy hostname, port, username and password, then open your session as usual. Save the session so the proxy is kept.

How do I use a SOCKS proxy with SSH on a Mac?

macOS includes the netcat that supports -X 5, so ProxyCommand nc -X 5 -x proxyhost:port %h %p works with an allowlisted IP. For a proxy login, install ncat with Homebrew's nmap package.

How do I make ssh use a SOCKS proxy for one host only?

Put the ProxyCommand inside that host's Host block in ~/.ssh/config. Other hosts keep connecting directly; for a single command, pass -o ProxyCommand=... on the command line instead.

How do I use git over SSH through a SOCKS proxy?

Add a Host github.com (or your Git server) block with a ProxyCommand to ~/.ssh/config, or set GIT_SSH_COMMAND for one command. Git's SSH remotes then connect through the proxy.

Show 6 more questionsShow fewer questions

Does a SOCKS proxy over SSH carry UDP?

No. ssh -D forwards TCP connections only, and SSH itself runs over TCP. Apps that need UDP, such as many games and calls, don't work through it.

What is a reverse SOCKS proxy over SSH?

ssh -R 1080 user@server (OpenSSH 7.6 or later) opens a SOCKS proxy on the server whose traffic exits from your own computer. It's the mirror image of ssh -D.

Will my SSH session's IP change with a rotating proxy?

Not during a session: one SSH session is one connection and keeps its IP. New connections may get new IPs, so use a sticky session, or a dedicated ISP IP from $2.29 per 30 days, when the server should see one address.

Can I buy an SSH proxy from ProxyField?

ProxyField doesn't sell SSH accounts or SSH tunnels. It sells residential and mobile proxies over SOCKS5, HTTP and HTTPS from $1.95/GB; ask our 24/7 live chat whether the gateway carries SSH connections before you buy for SSH.

Is port forwarding safe for SSH connections?

The forwarded traffic is encrypted between you and the SSH server, but anything a forward exposes can be reached by whoever can reach that port. Keep -D and -L forwards on 127.0.0.1 (the default) and close them when you're done.

What is SSH?

Secure Shell, a protocol for logging in to and running commands on a remote computer over an encrypted connection, usually on port 22. It can also forward ports and act as a SOCKS proxy with -D.

Easy Trial: 1 GB for $2.95.

Try for the price of 1 GB, no subscription, traffic never expires.