Connect to an SSH server over an HTTP proxy using plink and netcat

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?

0
задан 20 July 2018 в 04:58
2 ответа

Спасибо за вопрос, я добился успеха в Window 10 1903 через open ssh, ниже моя команда:

 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

С plink: Release 0.71(64-bit), команда OP работает нормально, но cmd покажет некоторый нераспознанный график без цвета. Лучше использовать open ssh в 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
0
ответ дан 4 December 2019 в 15:53

В шпаклевке, в меню Конфигурация->Соединение->Прокси, вы можете настроить HTTP-прокси напрямую, без использования ncat.

В plink, вы можете обратиться к разделу Конфигурация шпаклевки. В тексте справки говорится

, что "хост" также может быть сохраненным именем сеанса PuTTY

, поэтому просто позвоните plink с сохраненной конфигурацией.

.
1
ответ дан 4 December 2019 в 15:53

Теги

Похожие вопросы