Connecting to host by SSH client in Linux by proxy

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.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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' <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b6c3c5d3c4f6ded9c5c2">[email protected]</a>

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"' <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c2b7b1a7b082aaadb1b6">[email protected]</a>

For HTTP Proxy CONNECT method with socat 2:

ssh -o ProxyCommand='socat - "PROXY:%h:%p|tcp:myproxy:80"' <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bbcec8dec9fbd3d4c8cf">[email protected]</a>

Method 2

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

Method 3

For HTTP Proxy CONNECT method with socat,

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


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x