Visual Studio Code 远程 SSH 通过 SSH 代理连接

8
我正在尝试使用vs-code的remote-ssh extension通过ssh隧道连接到服务器。 该服务器是内部集群的一部分,没有公共IP地址,我通过集群中的代理使用link中概述的方法进行连接:
# ~/.ssh/config
Host internal*
User root
ProxyCommand ssh user@firewall 'nc %h %p'

当我尝试连接内部服务器时,出现以下错误对话框:

无法建立到“internal-server”的连接。该进程尝试写入一个不存在的管道。

输出窗口的日志:
remote-ssh@0.45.6
win32 x64
SSH Resolver called for "ssh-remote+internal-server", attempt 1
SSH Resolver called for host: internal-server
Setting up SSH remote "internal-server"
Using commit id "........" and quality "stable" for server
Testing ssh with ssh -V
ssh exited with code: 0
Got stderr from ssh: OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
Running script with connection command: ssh -o ClearAllForwardings=true internal-server bash
Install and start server if needed
> 
Got some output, clearing connection timeout
> ]0;C:\WINDOWS\SYSTEM32\cmd.exe
> 
> CreateProcessW failed error:2
> 
> posix_spawn: No such file or directory
> The process tried to write to a nonexistent pipe.
> 
"install" terminal command done
Install terminal quit with output: The process tried to write to a nonexistent pipe.
Received install output: The process tried to write to a nonexistent pipe.
The process tried to write to a nonexistent pipe
TELEMETRY: {"eventName":"resolver","properties":{"outcome":"failure","reason":"OfflineError"},"measures":{"resolveAttempts":1,"retries":1}}
------

如何使用vs-code的远程ssh连接代理/防火墙后的计算机?
2个回答

10
对于遇到相同问题的人,我通过提供ssh的绝对路径解决了这个问题,例如:
ProxyCommand C:\Windows\System32\OpenSSH\ssh.exe -W %h:%p server

这应该是被接受的答案!感谢您的帮助,这解决了我的问题!Windows出于某种原因需要知道我的ProxyCommand在哪里 X_x。 - Nathaniel Ruiz
3
我应该在哪里添加它?在远程SSH配置文件中吗? - aderchox

0

目前我已经探索了两个可能的原因。

  1. 您遇到此错误是因为ssh文件的配置/冲突。对我有用的是,我有一个名为“C:\ Users \ gur51262”的目录,其中包含ssh配置,但还有另一个目录,路径为“C:\ ProgramData \ ssh”,其中有一个名为“ssh_config”的文件,可能会与它产生冲突。

所以我只配置了位于“C:\ Users \ gur51262”路径上的文件,并省略了位于“C:\ ProgramData \ ssh”路径上的其他文件的内容。

还要确保您遵循配置文件的语法(如果有)。例如:

Host host203
  HostName 172.19.51.203
  User root 

解决方案适用于Windows 7。

  • ".ssh/config"文件中可能会出现冲突的情况。可能会有主机名的重复条目,如下所示:

    Host 172.19.51.212
      HostName 172.19.51.212
    Host 172.19.51.212
      HostName 172.19.51.212
      User root
    

  • 网页内容由stack overflow 提供, 点击上面的
    可以查看英文原文,
    原文链接