3

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

7

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
1
  • 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. Jun 4, 2018 at 0:31
2

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

1

For HTTP Proxy CONNECT method with socat,

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.