So I ran into a situation where I needed to tunnel my SSH connections through a SOCKS5 proxy. I discovered through the googles that this is actually possible right through SSH itself meaning no jenky hack arounds.

All you need to do is ensure you have “nc” installed (netcat) and add the following to either your command or config file:

CLI:

-o ‘ProxyCommand /usr/bin/nc -x localhost:3128 %h %p’

Config:

ProxyCommand /usr/bin/nc -x localhost:3128 %h %p

It’s as easy as that! Just a note that for your config file, that statement above would obviously go under your “Host blah” heading defining the specifics for a certain host.

Whats awesome is you can also define a ssh tunnel (forward) in your config too!

DynamicForward localhost:3128

Thanks to this guy.

Mario Loria is a builder of diverse infrastructure with modern workloads on both bare-metal and cloud platforms. He's traversed roles in system administration, network engineering, and DevOps. You can learn more about him here.