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.

Blog Logo

Mario Loria


Published

Image

./scriptthe.net

Because 127.0.0.1 gets old after a while.

Back to Overview