在我的工作中,我们有一个跳转主机,我必须通过它连接到集群。通常,连接语句将是
ssh -t herp@jumphost ssh cluster
此外,此连接必须在公司 VPN 内进行。现在,我想cluster
使用 Windows 10 上的 VS Code 进行连接。这会产生几个问题。这篇博文建议为此使用 ssh 配置文件,因此我在 C:\Users\Herp\.ssh\config 中添加了以下几行:
Host jumphost
HostName jumphost
User herp
Host cluster-work
User herp
HostName cluster
ProxyCommand ssh -tt jumphost
然后,当我尝试使用cmd.exe
或连接时,PowerShell
我得到:
$ ssh cluster -v
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug1: Reading configuration data C:\\Users\\Herp/.ssh/config
debug1: C:\\Users\\Herp/.ssh/config line 18: Applying options for cluster-work
debug1: Executing proxy command: exec ssh -tt jumphost
debug1: identity file [...]
[...]
debug1: identity file [...]
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1
herp@jumphost's password: <I enter the PW>
debug1: kex_exchange_identification: banner line 0: Last login: Mon Jun 28 20:50:42 2021 from <some IP>
debug1: kex_exchange_identification: banner line 1:
debug1: Remote protocol version 2.0, remote software version OpenSSH_for_Windows_8.1
debug1: match: OpenSSH_for_Windows_8.1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to cluster:22 as 'herp'
debug1: SSH2_MSG_KEXINIT sent
Bad packet length 218783296.
ssh_dispatch_run_fatal: Connection to UNKNOWN port 65535: message authentication code incorrect
有时,最后几行会变成
debug1: kex_exchange_identification: banner line 0: Last login: Mon Jun 28 20:50:42 2021 from <some IP>
debug1: kex_exchange_identification: banner line 1:
debug1: kex_exchange_identification: banner line 2: \033]0;herp@cluster:~\033[?1034h[herp@cluster ~]$ SSH-2.0-OpenSSH_for_Windows_8.1
debug1: kex_exchange_identification: banner line 3: -bash: SSH-2.0-OpenSSH_for_Windows_8.1: command not found
debug1: kex_exchange_identification: banner line 4: \033]0;herp@cluster:~[herp@cluster ~]$
如果我使用-t
而不是,则-tt
输入ProxyCommand
密码之前和之后的最后几行是
Pseudo-terminal will not be allocated because stdin is not a terminal.
herp@jumphost's password: <I enter the PW>
-bash: line 1: $'SSH-2.0-OpenSSH_for_Windows_8.1\r': command not found
然后就cmd.exe
冻结了所以我不得不关闭窗口。
我怎样才能使此连接正常工作?
更新
使用-J
标志而不是-t
导致:
> ssh -J herp@jumphost herp@cluster
herp@jumphost's password: <I enter the PW>
channel 0: open failed: administratively prohibited: open failed
stdio forwarding failed
更新 2
我在 WSL 中重复了此操作,结果相同。所以这不仅仅是 Windows 10 的问题。