VS Code Remote SSH无法连接服务器,卡在Opening Remote求助
VS Code Remote-SSH 卡在“Opening Remote”界面,报错“find: No match”
问题描述
之前VS Code SSH长时间等待输入密码后关闭连接,再次尝试SSH连接时卡在“Opening Remote”界面。之前遇到同类问题时,删除服务器端.vscode/和.vscode-server/目录即可恢复,但此次操作无效。
连接时终端日志多次出现find: No match错误,且服务器端未生成.vscode-server目录。已尝试重装客户端VS Code、使用“Remote-SSH: Kill VS Code Server on Host”选项,问题仍未解决。
版本信息
- VS Code版本:1.91.1(commit id:f1e16e1e6214d7c44d078b1f0607b2388f29d729,x64)
- Remote-SSH扩展版本:v0.113.1
日志详情
[11:13:27.211] Log Level: 2 [11:13:27.219] SSH Resolver called for "ssh-remote+vm-name.domain-name.com", attempt 1 [11:13:27.220] "remote.SSH.useLocalServer": false [11:13:27.220] "remote.SSH.useExecServer": true [11:13:27.220] "remote.SSH.showLoginTerminal": false [11:13:27.220] "remote.SSH.remotePlatform": {} [11:13:27.221] "remote.SSH.path": undefined [11:13:27.221] "remote.SSH.configFile": undefined [11:13:27.221] "remote.SSH.useFlock": true [11:13:27.221] "remote.SSH.lockfilesInTmp": false [11:13:27.221] "remote.SSH.localServerDownload": auto [11:13:27.221] "remote.SSH.remoteServerListenOnSocket": false [11:13:27.221] "remote.SSH.showLoginTerminal": false [11:13:27.221] "remote.SSH.defaultExtensions": [] [11:13:27.221] "remote.SSH.loglevel": 2 [11:13:27.222] "remote.SSH.enableDynamicForwarding": true [11:13:27.222] "remote.SSH.enableRemoteCommand": false [11:13:27.222] "remote.SSH.serverPickPortsFromRange": {} [11:13:27.222] "remote.SSH.serverInstallPath": {} [11:13:27.222] "remote.SSH.permitPtyAllocation": false [11:13:27.225] "remote.SSH.preferredLocalPortRange: undefined [11:13:27.225] "remote.SSH.useCurlAndWgetConfigurationFiles: false [11:13:27.231] VS Code version: 1.91.1 [11:13:27.231] Remote-SSH version: remote-ssh@0.113.1 [11:13:27.232] win32 x64 [11:13:27.234] SSH Resolver called for host: vm-name.domain-name.com [11:13:27.234] Setting up SSH remote "vm-name.domain-name.com" [11:13:27.237] Using commit id "f1e16e1e6214d7c44d078b1f0607b2388f29d729" and quality "stable" for server [11:13:27.240] Install and start server if needed [11:13:29.691] Checking ssh with "C:\WINDOWS\system32\ssh.exe -V" [11:13:29.695] Got error from ssh: spawn C:\WINDOWS\system32\ssh.exe ENOENT [11:13:29.695] Checking ssh with "C:\WINDOWS\ssh.exe -V" [11:13:29.697] Got error from ssh: spawn C:\WINDOWS\ssh.exe ENOENT [11:13:29.697] Checking ssh with "C:\WINDOWS\System32\Wbem\ssh.exe -V" [11:13:29.698] Got error from ssh: spawn C:\WINDOWS\System32\Wbem\ssh.exe ENOENT [11:13:29.698] Checking ssh with "C:\WINDOWS\System32\WindowsPowerShell\v1.0\ssh.exe -V" [11:13:29.700] Got error from ssh: spawn C:\WINDOWS\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT [11:13:29.700] Checking ssh with "C:\WINDOWS\System32\OpenSSH\ssh.exe -V" [11:13:29.908] > OpenSSH_for_Windows_8.6p1, LibreSSL 3.4.3 [11:13:29.913] Running script with connection command: "C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 50167 "vm-name.domain-name.com" bash [11:13:29.916] Terminal shell path: C:\WINDOWS\System32\cmd.exe [11:13:30.964] > username@vm-name.domain-name.com's password:]0;C:\WINDOWS\System32\cmd.exe [11:13:30.965] Got some output, clearing connection timeout [11:13:30.965] Showing password prompt [11:13:38.329] Got password response [11:13:38.329] "install" wrote data to terminal: "***************" [11:13:38.395] > [11:13:38.982] > find: No match. [11:13:39.110] > find: No match. [11:13:39.243] > find: No match.
解决方案
1. 修正服务器端Shell环境
find: No match报错大概率是服务器默认Shell不是Bash,或Shell的glob匹配规则导致VS Code安装脚本执行失败:
- 登录服务器,执行
echo $SHELL确认默认Shell。若不是Bash,执行chsh -s /bin/bash切换,重新登录后再尝试连接。 - 若无法切换Shell,可在本地
~/.ssh/config(Windows路径:C:\Users\<你的用户名>\.ssh\config)中添加配置,强制连接时使用Bash:Host vm-name.domain-name.com HostName vm-name.domain-name.com User username RequestTTY force RemoteCommand bash
2. 手动安装VS Code Server
自动安装失败时,手动上传对应版本的Server包:
- 在VS Code命令面板(Ctrl+Shift+P)执行
Remote-SSH: Show Local Server Log,找到类似https://update.code.visualstudio.com/commit:<你的commit id>/server-linux-x64/stable的下载链接(根据服务器系统选择对应包)。 - 下载压缩包后,上传到服务器
~/.vscode-server/bin/<你的commit id>/目录(不存在则手动创建)。 - 解压包:
unzip vscode-server-linux-x64.zip -d ~/.vscode-server/bin/<你的commit id>/ - 重启VS Code后尝试连接。
3. 清理客户端本地缓存
Windows下清理VS Code相关缓存:
- 关闭VS Code,删除
C:\Users\<你的用户名>\.vscode\extensions\ms-vscode-remote.remote-ssh-0.113.1目录(版本号对应你的Remote-SSH版本)。 - 删除
C:\Users\<你的用户名>\AppData\Roaming\Code\CachedData\<你的commit id>目录。 - 重启VS Code,重装Remote-SSH扩展后重试连接。
4. 手动测试SSH连接
在本地CMD执行日志中的SSH命令:"C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 50167 "vm-name.domain-name.com" bash,查看是否能正常进入服务器Bash环境,排查是否有其他隐藏错误。
内容的提问来源于stack exchange,提问作者N. Vakharia
相关产品推荐
相关产品推荐

