ssh through socks server

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
First off...let me state...I am more knowledgeable of AIX than standard
Linux so I am going to refer to what I do on AIX...

I have a set of servers that I have to use a ssh proxy to access. In AIX I
was able to add a /etc/socks5c.conf file with the socks entries like this:
Destination / Netmask Socks5_proxy_server_port (1080)

I then added SOCKS5C_CONFIG=/etc/socks5c.conf to /etc/environment and ALL
users on this machine can now access the "Destination" server from above by
ssh Destination (with no flags or anything).

I need to be able to do this on Linux also. I can NOT use -D/-P or whatever
flags on the ssh for this server because I need to do this in a script that
does ssh to various machines and none of the others use any weird -D/-P or
whatever flags.

Is this possible? To restate...I want to ssh to these socks proxy servers as
if they were on the local network by just doing:
ssh Destination


Re: ssh through socks server

Quoted text here. Click to load it

There's no Linux equivalent to the system-wide SOCKSification on AIX
(at least, not in any of the distros I've seen).

You could potentially do something like it by using one of the
LD_PRELOAD-able SOCKS libraries (eg the one used by "runsocks" from the
old NEC SOCKS package or "socksify" from Dante) and setting LD_PRELOAD
in the system startup scripts.

Quoted text here. Click to load it

With OpenSSH, the most common way to do this is to use a ProxyCommand
that supports SOCKS, eg connect[1] or netcat.  You put something like
this into your ~/.ssh/config or system-wide ssh_config:

Host somehost
    ProxyCommand connect -S %h %p

and then "ssh somehost" should just work.  You can also use "Host *" at
the bottom of the config to use your SOCKS server by default.


Darren Tucker (dtucker at
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4  37C9 C982 80C7 8FF4 FA69
    Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.

Site Timeline