SSHing thru an HTTP proxy

0

Typical scenario: I'm trying to SSH thru a corporate HTTP proxy to a remote machine using corkscrew, and I get:

ssh_exchange_identification: Connection closed by remote host

Obviously, there's a lot of reasons this might be happening - the proxy might not allow this, the remote box might not be running sshd, etc.

So, I tried to tunnel manually via telnet:

$ telnet proxy.evilcorporation.com 82
Trying XX.XX.XX.XX...
Connected to proxy.evilcorporation.com.
Escape character is '^]'.
CONNECT myremotehost.com:22 HTTP/1.1

HTTP/1.1 200 Connection established

So, unless I'm mistaken... it looks like the connection is working.

So, why then, doesn't it work via corkscrew?

ssh -vvv root@myremotehost.com -p 22 -o "ProxyCommand corkscrew proxy.evilcorporation.com 82 myremotehost.com 22"
OpenSSH_6.6, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Executing proxy command: exec corkscrew proxy.evilcorporation.com 82 myremotehost.com 22
debug1: permanently_set_uid: 0/0
debug1: permanently_drop_suid: 0
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6p1 Ubuntu-2ubuntu1
ssh_exchange_identification: Connection closed by remote host

Siler

Posted 2014-05-30T18:57:30.993

Reputation: 279

You've established a connection on port 22 via CONNECT, but have you actually tried an SSH handshake through it? Perhaps the proxy detects SSH, which is easy, and drops the connection. – Icydog – 2014-05-31T00:57:22.377

Answers

0

It is possible that you are trying to tunnel through a proxy against which corkscrew has not been designed/tested/debugged. Corkscrew's home page states (verbatim):

Corkscrew has been tested with the following HTTP proxies :

Gauntlet

CacheFlow

JunkBuster

Squid

Apache's mod_proxy

Please email me if you get it to work with another proxy

Do you know which proxy is run, in your case?

MariusMatutiae

Posted 2014-05-30T18:57:30.993

Reputation: 41 321

0

You can check whether corkscrew is working correctly by running your proxycommand directly on the commandline. In your case, running

corkscrew proxy.evilcorporation.com 82 myremotehost.com 22

should produce output like

SSH-2.0-OpenSSH_6.7

I.e. the SSH protocol banner from the remote server. If this doesn't work, then something is wrong with your proxy and/or your ssh server.

djm

Posted 2014-05-30T18:57:30.993

Reputation: 76