首页 > 解决方案 > 通过 ssh 远程编辑到 windows 服务器

问题描述

远程 SSH插件声明 VS Code Insiders 使用官方 OpenSSH 服务器对 Windows 10/Server 1803+ 提供实验性支持。

我在 Windows Server 2019 1809 上安装并配置了官方 OpenSSH 服务器。我可以通过 pubkey 身份验证进行连接,并且 PowerShell Core over ssh 也可以正常工作。我尝试了 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/Server 一起工作的秘诀吗?

标签: visual-studio-codevscode-remote

解决方案


看起来 VSCode 正在尝试在服务器上运行 bash,我猜它会解析为 git 的 bash,据我回忆,它是基于 mingw 的。VSCode 应该在服务器上运行 Powershell。

您是否将您的服务器包含在扩展程序设置的 Windows 遥控器列表中?


推荐阅读