9

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.

w5m
  • 2,286
  • 3
  • 34
  • 46
Agus
  • 1,604
  • 2
  • 23
  • 48

2 Answers2

10

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.

Andy Ross
  • 11,699
  • 1
  • 34
  • 31
  • 1
    also add "-X connect" if you are going through an http(s) proxy instead of a SOCKS one. ref: http://betterlogic.com/roger/2014/01/ssh-how-to-tunnel-through-an-http-proxy/ – rogerdpack Jan 07 '14 at 23:01
6

There are several ways to do it. You can use nc or try wrappers like corkscrew. I'll describe way with wrapeer:

Firstly install corkscrew by apt-get
Then you need to specify ProxyCommand in your ./ssh/config file (replace example-proxy.com and 8080 with your proxy host and port):

Host *
  ProxyCommand corkscrew example-proxy.com 8080 %h %p ~/.ssh/proxyauth

Your login credentials should be in ~/.ssh/proxyauth in format:

login:password