Ubuntu – Using ssh and corkscrew/proxychains behing a HTTP proxy

PROXYsshtunnelingUbuntu

The Ubuntu box I am looking at is behind a proxy which supports CONNECT to 80/443 ports. I have set up an outside ssh server on port 443 and can connect to it with corkscrew / ssh without any problems

ssh_config:

Host *
    ProxyCommand corkscrew corp.proxy.ip 8080 %h %p 

command line to start ssd:

ssh -D 1080 username@external-host.com -p 443

So as I said it all works just fine. The problem is though that -D parameter, which supposed to open up a SOCKS proxy does not quite work.

When I run proxychains that's what I get:

 user@laptop:$ proxychains git pull
 ProxyChains-3.1 (http://proxychains.sf.net)
 random chain (1):....127.0.0.1:1080....can't connect to..corp.proxy.ip:8080

So it seem to initiate a connection to proxy again for some reason.

Similar set up works just fine on windows machine (Bitvise Tunneller/Freecap), all tunnelling works fine.

I have tried to that:

  1. started ssh with -D, having proxy in the config
  2. commented proxy while (1) still runs
  3. ran proxychains

This time ssh did not try to connect to the proxy and connection went fine, but editing config every time back and forth is hardly a solution.

So any ideas how to fix properly?

Thanks!

Best Answer

Solution is quite simple after all: make ssh connect to proxy ONLY when it needs to establish a tunnel for the first time:

ssh_config:

Host external-host.com
    ProxyCommand corkscrew corp.proxy.ip 8080 %h %p

That works cool.

Thanks for watching, everybody :)

Related Topic