Connecting to host by SSH client in Linux by proxy

Agus picture Agus · Mar 22, 2013 · Viewed 27.5k times · Source

I am really struggling with this.

My host (A) is behind a proxy/firewall (PF) and needs to connect to host H.

The proxy has HTTP/FTP/SOCK proxy configured and I have no issue to configure in web browser, wget etc.

But when I use...

ssh H //to connect my host 

I have no success to pass over the proxy. It seems to try to connect directly instead of going via the PF.

I am using Ubuntu 12.10.

Answer

Andy Ross picture Andy Ross · Mar 22, 2013

Check the docs for the ssh ProxyCommand option. You can specify a command to run (for example, nc) to connect to a given host and port. For example, adding this to your .ssh/config might work to traverse a SOCKS5 proxy:

ProxyCommand nc -x MY_PROXY_HOST:MY_PROXY_PORT %h %p

More detailed instructions are going to depend on your environment.