Search code examples
sshtunneltunneling

SSH over SSH (or How to 'proxify' SSH through SSH)


I'm looking for a methodology to SSH over SSH (as in the title).

So, I know I can do :

ssh -t user1@proxyServer ssh user2@farAwayServer

Or I can use the ProxyCommand with nc, but I don't want to use one connection to the proxyServer by connection to every farAwayServer. And I know I can use ControlMaster, but I'm not really happy with this solution too.

I rather prefer something like :

ssh -t -Dlocalhost:2222 user1@proxyServer
ssh (something to use the localhost:2222) user2@farAwayServer

Is this solution exist and if Yes how ?

Thanks for your help


Solution

  • ProxyChains or tsocks would allow you to redirect ssh network connections through the SOCKS proxy.

    Another option is to use socat (that understands SOCKS4/5) combined with the ProxyCommand.