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.

3 Answers 3


ssh has no native SOCKS client support, you need to use a ProxyCommand for that, for instance with socat:

ssh -o ProxyCommand='socat - SOCKS4A:myproxy:%h:%p,socksuser=nobody' user@host

Or use things like tsocks or dante's socksify to transparently use SOCKS for TCP traffic.

For SOCKS5 with socat 2:

ssh -o ProxyCommand='socat - "SOCKS5:%h:%p|tcp:myproxy:1080"' user@host

For HTTP Proxy CONNECT method with socat 2:

ssh -o ProxyCommand='socat - "PROXY:%h:%p|tcp:myproxy:80"' user@host
  • Awesome!! The socat SOCKS4A was the one that worked for me. I needed to clone a git repository behind a proxy into a corporate VPN. I created my socks proxy to the machine that's connected to the VPN (ssh -D 9999), then configured the client's SSH config to connect to the behindfirewall.corporate.com by using the socat command as the ProxyCommand into the SOCKS proxy host. The SOCKS4A also uses the proxy server to resolve DNS which was a problem with other solutions. Commented Jun 4, 2018 at 0:31

Check Corkscrew or Proxytunnel (and be aware that tunnelling SSH through a proxy be forbidden by local policies in some networks).


For HTTP Proxy CONNECT method with socat,

ProxyCommand: socat - PROXY:myproxy:%h:%p,proxyport=myproxyport

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .