ssh连接失败(Visual Studio Code 无法与“xxx”建立连接。 关闭远程 重试 使用Copilot进行诊断 更多操作....)
·
[10:20:33.439] Log Level: 2
[10:20:33.458] SSH Resolver called for "ssh-remote+raspberrypi_3b", attempt 1
[10:20:33.474] remote.SSH.useLocalServer = false
[10:20:33.475] remote.SSH.useExecServer = true
[10:20:33.476] remote.SSH.bindHost = {}
[10:20:33.477] remote.SSH.showLoginTerminal = true
[10:20:33.478] remote.SSH.remotePlatform = {"ubuntu":"linux","192.168.207.132":"linux","ubuntu_ArtinChip":"linux","ubuntu_K1_3568":"linux","ATK3568_board":"linux","ubuntu_rk628":"linux","raspberrypi_3b":"linux"}
[10:20:33.479] remote.SSH.path =
[10:20:33.479] remote.SSH.configFile =
[10:20:33.480] remote.SSH.useFlock = true
[10:20:33.481] remote.SSH.lockfilesInTmp = false
[10:20:33.482] remote.SSH.localServerDownload = auto
[10:20:33.483] remote.SSH.remoteServerListenOnSocket = false
[10:20:33.484] remote.SSH.defaultExtensions = []
[10:20:33.485] remote.SSH.defaultExtensionsIfInstalledLocally = []
[10:20:33.485] remote.SSH.loglevel = 2
[10:20:33.486] remote.SSH.enableDynamicForwarding = true
[10:20:33.487] remote.SSH.enableRemoteCommand = false
[10:20:33.488] remote.SSH.serverPickPortsFromRange = {}
[10:20:33.489] remote.SSH.serverInstallPath = {}
[10:20:33.491] remote.SSH.permitPtyAllocation = false
[10:20:33.491] remote.SSH.preferredLocalPortRange = undefined
[10:20:33.492] remote.SSH.useCurlAndWgetConfigurationFiles = false
[10:20:33.493] remote.SSH.experimental.chat = true
[10:20:33.494] remote.SSH.experimental.enhancedSessionLogs = true
[10:20:33.494] remote.SSH.httpProxy = {"*":""}
[10:20:33.495] remote.SSH.httpsProxy = {"*":""}
[10:20:33.504] VS Code version: 1.124.0
[10:20:33.506] Remote-SSH version: remote-ssh@0.124.0
[10:20:33.507] win32 x64
[10:20:33.514] SSH Resolver called for host: raspberrypi_3b
[10:20:33.515] Setting up SSH remote "raspberrypi_3b"
[10:20:33.530] Using commit id "1b50d58d73426c9171299ec4037d01365d995b78" and quality "stable" for server
[10:20:33.531] Extensions to install:
[10:20:33.549] Install and start server if needed
[10:20:33.560] Checking ssh with "C:\Python314\Scripts\ssh.exe -V"
[10:20:33.564] Got error from ssh: spawn C:\Python314\Scripts\ssh.exe ENOENT
[10:20:33.566] Checking ssh with "C:\Python314\ssh.exe -V"
[10:20:33.568] Got error from ssh: spawn C:\Python314\ssh.exe ENOENT
[10:20:33.569] Checking ssh with "D:\python3.13.9\Scripts\ssh.exe -V"
[10:20:33.571] Got error from ssh: spawn D:\python3.13.9\Scripts\ssh.exe ENOENT
[10:20:33.572] Checking ssh with "D:\python3.13.9\ssh.exe -V"
[10:20:33.573] Got error from ssh: spawn D:\python3.13.9\ssh.exe ENOENT
[10:20:33.574] Checking ssh with "C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler\ssh.exe -V"
[10:20:33.576] Got error from ssh: spawn C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler\ssh.exe ENOENT
[10:20:33.577] Checking ssh with "C:\Program Files (x86)\Common Files\Oracle\Java\javapath\ssh.exe -V"
[10:20:33.579] Got error from ssh: spawn C:\Program Files (x86)\Common Files\Oracle\Java\javapath\ssh.exe ENOENT
[10:20:33.580] Checking ssh with "D:\vmware16\bin\ssh.exe -V"
[10:20:33.581] Got error from ssh: spawn D:\vmware16\bin\ssh.exe ENOENT
[10:20:33.582] Checking ssh with "C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common\ssh.exe -V"
[10:20:33.584] Got error from ssh: spawn C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common\ssh.exe ENOENT
[10:20:33.584] Checking ssh with "C:\WINDOWS\system32\ssh.exe -V"
[10:20:33.586] Got error from ssh: spawn C:\WINDOWS\system32\ssh.exe ENOENT
[10:20:33.587] Checking ssh with "C:\WINDOWS\ssh.exe -V"
[10:20:33.588] Got error from ssh: spawn C:\WINDOWS\ssh.exe ENOENT
[10:20:33.589] Checking ssh with "C:\WINDOWS\System32\Wbem\ssh.exe -V"
[10:20:33.590] Got error from ssh: spawn C:\WINDOWS\System32\Wbem\ssh.exe ENOENT
[10:20:33.591] Checking ssh with "C:\WINDOWS\System32\WindowsPowerShell\v1.0\ssh.exe -V"
[10:20:33.593] Got error from ssh: spawn C:\WINDOWS\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT
[10:20:33.593] Checking ssh with "C:\WINDOWS\System32\OpenSSH\ssh.exe -V"
[10:20:33.661] > OpenSSH_for_Windows_9.5p2, LibreSSL 3.8.2
[10:20:33.668] Running script with connection command: "C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 61751 "raspberrypi_3b" sh
[10:20:33.670] Generated SSH command: 'type "C:\Users\ADMINI~1\AppData\Local\Temp\vscode-linux-multi-line-command-raspberrypi_3b-293807461.sh" | "C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 61751 "raspberrypi_3b" sh'
[10:20:33.671] Using connect timeout of 17 seconds
[10:20:33.673] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[10:20:33.854] >
[10:20:33.856] Got some output, clearing connection timeout
[10:20:33.859] >
[10:20:34.106] > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
> Someone could be eavesdropping on you right now (man-in-the-middle attack)!
> It is also possible that a host key has just been changed.
> The fingerprint for the ED25519 key sent by the remote host is
> SHA256:f/4C6851SjkOe3yAMKvC5Rj/qSokqfXr+6d8n60OSCU.
> Please contact your system administrator.
> Add correct host key in C:\\Users\\Administrator/.ssh/known_hosts to get rid of this message.
> Offending ECDSA key in C:\\Users\\Administrator/.ssh/known_hosts:16
> Host key for 192.168.5.20 has changed and you have requested strict checking.
> Host key verification failed.
[10:20:34.111] > 过程试图写入的管道不存在。
[10:20:34.422] "install" terminal command done
[10:20:34.423] Install terminal quit with output: 过程试图写入的管道不存在。
[10:20:34.424] Received install output: 过程试图写入的管道不存在。
[10:20:34.425] WARN: $PLATFORM is undefined in installation script output. Errors may be dropped.
[10:20:34.427] Failed to parse remote port from server output
[10:20:34.428] Resolver error: Error
at y.Create (c:\Users\Administrator\.vscode\extensions\ms-vscode-remote.remote-ssh-0.124.0\out\extension.js:2:722235)
at t.handleInstallOutput (c:\Users\Administrator\.vscode\extensions\ms-vscode-remote.remote-ssh-0.124.0\out\extension.js:2:720316)
at t.tryInstall (c:\Users\Administrator\.vscode\extensions\ms-vscode-remote.remote-ssh-0.124.0\out\extension.js:2:842913)
at async c:\Users\Administrator\.vscode\extensions\ms-vscode-remote.remote-ssh-0.124.0\out\extension.js:2:801927
at async t.withShowDetailsEvent (c:\Users\Administrator\.vscode\extensions\ms-vscode-remote.remote-ssh-0.124.0\out\extension.js:2:805164)
at async A (c:\Users\Administrator\.vscode\extensions\ms-vscode-remote.remote-ssh-0.124.0\out\extension.js:2:798392)
at async t.resolve (c:\Users\Administrator\.vscode\extensions\ms-vscode-remote.remote-ssh-0.124.0\out\extension.js:2:802578)
at async c:\Users\Administrator\.vscode\extensions\ms-vscode-remote.remote-ssh-0.124.0\out\extension.js:2:1095642
[10:20:34.437] ------
[10:20:34.439] No hints found in the recent session.
[10:20:34.813] Opening exec server for ssh-remote+raspberrypi_3b
[10:20:34.880] Initizing new exec server for ssh-remote+raspberrypi_3b
[10:20:34.884] Using commit id "1b50d58d73426c9171299ec4037d01365d995b78" and quality "stable" for server
[10:20:34.885] Extensions to install:
[10:20:34.900] Install and start server if needed
[10:20:34.910] Running script with connection command: "C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 61751 "raspberrypi_3b" sh
[10:20:34.911] Generated SSH command: 'type "C:\Users\ADMINI~1\AppData\Local\Temp\vscode-linux-multi-line-command-raspberrypi_3b-620871237.sh" | "C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 61751 "raspberrypi_3b" sh'
[10:20:34.912] Using connect timeout of 17 seconds
[10:20:34.914] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[10:20:35.025] >
[10:20:35.026] Got some output, clearing connection timeout
[10:20:35.040] >
[10:20:35.210] > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
> Someone could be eavesdropping on you right now (man-in-the-middle attack)!
> It is also possible that a host key has just been changed.
> The fingerprint for the ED25519 key sent by the remote host is
> SHA256:f/4C6851SjkOe3yAMKvC5Rj/qSokqfXr+6d8n60OSCU.
> Please contact your system administrator.
> Add correct host key in C:\\Users\\Administrator/.ssh/known_hosts to get rid of this message.
> Offending ECDSA key in C:\\Users\\Administrator/.ssh/known_hosts:16
> Host key for 192.168.5.20 has changed and you have requested strict checking.
> Host key verification failed.
> 过程试图写入的管道不存在。
[10:20:35.235] >
[10:20:35.536] "install" terminal command done
[10:20:35.537] Install terminal quit with output: 过程试图写入的管道不存在。
[10:20:35.538] Received install output: 过程试图写入的管道不存在。
[10:20:35.540] WARN: $PLATFORM is undefined in installation script output. Errors may be dropped.
[10:20:35.541] Failed to parse remote port from server output
[10:20:35.542] Exec server for ssh-remote+raspberrypi_3b failed: Error
[10:20:35.542] Error opening exec server for ssh-remote+raspberrypi_3b: Error
[10:20:35.543] No hints found in the recent session.
日志核心问题一眼定位
报错关键文本:
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
Host key for 192.168.5.20 has changed and you have requested strict checking.
Host key verification failed.
原因
之前连过旧IP/重装/换系统后的树莓派,本地 known_hosts 缓存了旧密钥,现在设备密钥变了,OpenSSH 安全校验直接拒绝连接,管道断开,VSCode连不上。
修复步骤(按顺序执行,1分钟解决)
1. 删除本地冲突主机密钥(必做)
方式A:PowerShell/CMD执行一键清除
ssh-keygen -R 192.168.5.20
ssh-keygen -R raspberrypi_3b
执行完成会提示:# Host 192.168.5.20 found: line 16,已删除冲突行。
方式B:手动删除文件
路径:C:\Users\Administrator\.ssh\known_hosts
用记事本打开,删掉包含 192.168.5.20 的整行,保存关闭。
2. 先手动SSH登录一次,确认信任新密钥
打开CMD/PowerShell执行:
ssh hxkj@192.168.5.20
会弹出提示:
Are you sure you want to continue connecting (yes/no/[fingerprint])?
输入 yes 回车,输入密码正常进入树莓派终端。
这一步是让系统写入新的合法密钥,VSCode后续连接不会拦截。
3. 清理树莓派端旧VSCode服务(可选但推荐)
手动ssh连上树莓派后执行:
rm -rf ~/.vscode-server
exit
4. 重启VSCode重新连接
- 完全关闭VSCode所有窗口再打开
- 左侧远程面板找到
raspberrypi_3b,点击重试连接
补充说明
- 日志里ssh路径检索正常,Windows自带OpenSSH
C:\WINDOWS\System32\OpenSSH\ssh.exe可用,不是ssh工具缺失问题; 过程试图写入的管道不存在只是密钥校验失败后的连锁报错,根源只有主机密钥不匹配;- 后续如果再次重装树莓派、修改IP,重复执行
ssh-keygen -R IP即可。
兜底方案(上面操作无效时)
修改ssh配置关闭严格主机校验:
- VSCode远程SSH面板 → 右上角齿轮
Open SSH Configuration File - 选择
C:\Users\Administrator\.ssh\config
给我的 raspberrypi_3b 主机添加两行:
Host raspberrypi_3b
HostName 192.168.5.20
User hxkj
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
保存后重启VSCode直接连接,不会再校验密钥。
更多推荐



所有评论(0)