1

I'm trying to connect to an SSH server from a Windows PC behind a corporate HTTP proxy.

The trick works under Debian using OpenSSH client with ncat from the nmap package, but it does not work under Windows with Plink 0.70 + Ncat 7.70 (https://nmap.org). Putty works fine too, though using pure plink would be better for me.

Plink has the -proxycmd option, which seems to be similar to the ProxyCommand option in OpenSSH. However, it does not work as expected (SSH server is running on port 443):

plink.exe -C -ssh -P 443 -i my_pvt_key.ppk -proxycmd "ncat --verbose --proxy-type http --proxy 192.168.101.200:3128 %host %port" -sshlog sshlog.txt root@192.0.2.123

The command immediately returns "FATAL ERROR: Server unexpectedly closed network connection".

Putty log:

=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2018.07.19 07:38:28 =~=~=~=~=~=~=~=~=~=~=~=
Event Log: Writing new session log (SSH packets mode) to file: sshlog.txt
Event Log: Starting local proxy command: ncat --verbose --proxy-type http --proxy 192.168.101.200:3128 port
Event Log: We claim version: SSH-2.0-PuTTY_Release_0.70
Event Log: Server unexpectedly closed network connection

The third line of the log is confusing. There is the word 'port' in the end of the command, and it should have been replaced with the actual port. Host 192.0.2.123 is not shown at all.

The command ncat --verbose --proxy-type http --proxy 192.168.101.200:3128 192.0.2.123 443 itself seems to work fine. Thus, I suppose, the problem is that Plink doesn't parse arguments in the ncat command correctly. I am probably wrong.

Any ideas how to fix that?

Patrick Mevzek
  • 9,273
  • 7
  • 29
  • 42
Kenny Parker
  • 11
  • 1
  • 5

2 Answers2

2

In Putty, in Configuration->Connection->Proxy, you can configure a HTTP Proxy directly without using ncat.

In plink, you can refer to a Putty configuration. The help text says

"host" can also be a PuTTY saved session name

So just call plink with the configuration you saved.

RalfFriedl
  • 3,008
  • 4
  • 12
  • 17
1

Thanks you question, i success in Window 10 1903 via open ssh, below is my command:

 ssh root@domain.com -o "ProxyCommand C:\Program Files (x86)\Nmap\ncat.exe --verbose --proxy-type http --proxy 127.0.0.1:10801 %h %p" -v

With plink: Release 0.71(64-bit), OP command work fine, but cmd will show some not recognized chart without color. Better to use open ssh in windows 10?

plink.exe -C -ssh -P 27158 -i C:\Users\xxx\.ssh\test.ppk -proxycmd "ncat --verbose --proxy-type http --proxy 127.0.0.1:10801 %host %port" root@xxx.xxx-sshlog sshlog.txt
James
  • 111
  • 2