通过 ssh 远程编辑到 windows 服务器

Remote editing over ssh to windows server

Remote SSH plugin states VS Code Insiders has experimental support for Windows 10/Server 1803+ using the official OpenSSH server.

我在 Windows Server 2019 1809 上安装并配置了官方 OpenSSH 服务器。我可以通过公钥身份验证进行连接,并且也可以通过 ssh 运行 PowerShell Core。我尝试了 Remote SSH 和 Remote SSH nightly 插件。起初它抱怨找不到 bash。所以我安装了 git bash 并添加到系统路径中。尝试连接到我的 windows 服务器时出现以下错误:

[16:02:41.398] Log Level: 3
[16:02:41.399] remote-ssh-nightly@2019.12.24000
[16:02:41.399] darwin x64
[16:02:41.401] SSH Resolver called for "ssh-remote+myserver", attempt 1
[16:02:41.401] SSH Resolver called for host: myserver
[16:02:41.401] Setting up SSH remote "myserver"
[16:02:41.413] Using commit id "e74405d11443c5361c31e2bc341866d146eee206" and quality "insider" for server
[16:02:41.414] Testing ssh with ssh -V
[16:02:41.425] ssh exited with code: 0
[16:02:41.425] Got stderr from ssh: OpenSSH_7.9p1, LibreSSL 2.7.3
[16:02:41.430] Running script with connection command: ssh -T -D 51951 -o ConnectTimeout=15 myserver bash
[16:02:41.430] Install and start server if needed
[16:02:43.451] > 5122b1a5b835: running
> Unsupported architecture: MINGW64_NT-10.0-17763 x86_64
> 5122b1a5b835##27##
[16:02:43.452] Got some output, clearing connection timeout
[16:02:43.710] "install" terminal command done
[16:02:43.710] Install terminal quit with output: 5122b1a5b835##27##
[16:02:43.710] Received install output: 5122b1a5b835##27##
[16:02:43.710] Unsupported architecture
[16:02:43.711] Resolver error: The remote host's architecture is not supported
[16:02:43.714] ------

有人知道让远程 SSH 在 Windows 10/服务器上工作的神奇方法吗?

看起来 VSCode 正试图在服务器上 运行 bash,我猜这会解析为 git 的 bash,这是我记得基于 mingw。 VSCode 应该是 运行 服务器上的 ning Powershell。

您是否将您的服务器包含在扩展程序设置的 windows 个远程列表中?

需要"remote.SSH.windowsRemotes"设置。这里是 documentation.

"remote.SSH.windowsRemotes": ["myserver"]