SSH – Define Socks Proxy in ~/.ssh/config File

linuxport-forwardingPROXYssh

I now run this to have a socks proxy:

ssh -D1111 my_server

I want to add it to my .ssh/config file to ProxyCommand so that whenever I run ssh my_server, I can have a socks proxy.

I searched but did not find a proper answer.

This is what I tried so far:

Host my_server
  HostName IP
  User root
  Port 1994
  ProxyCommand ssh -D1111 %h:%p

Best Answer

Your try with ProxyCommand is a mistake.

ProxyCommand acts as an alternative for the raw TCP connection. It's useful in cases where you want the SSH connection (the one you're about to start) use something else than raw TCP when connecting to the server. It may be another SSH connection (a "manually defined" alternative to ProxyJump) or a more sophisticated contraption (example).

Your command line

ssh -D1111 my_server

specifies nothing like this. Remove the ProxyCommand line from your config.

-D in the command line corresponds to DynamicForward in the config file. Use this:

DynamicForward 1111
Related Question