英文:
VS Code SSH keeps dropping connections, but I can SSH just fine
问题 {#heading}
我在远程机器和本地机器上设置了SSH,目的是使用VS Code SSH。我可以使用命令行中的ssh
连接到我的远程机器,但是VS Code在成功连接后不断断开连接,显示类似ssh child died, shutting down
的消息。
为什么我可以通过命令行SSH连接,但不能在VS Code中连接?我该如何修复这个问题?
背景 {#heading-1}
- 设置
- 验证
ssh -l REDACTED\citelao citelao-machine -vvv
工作正常- 我确认我正在使用OpenSSH的
ssh-agent
(https://stackoverflow.com/questions/60819352/how-can-i-use-windows-built-in-openssh-ssh-agent-in-vs-code-instead-of-git-bas/60821774#60821774) - 我在服务器上打开了超级详细的日志,但没有找到任何可疑的内容(Starting OpenSSH server in Windows with debug messages enabled (-d))
- 我尝试增加了
ServerAliveInterval 60
和ServerAliveCountMax 30
- 我尝试了
PubkeyAuthentication no
和PasswordAuthentication yes
(以及使用公钥身份验证尝试)
我该如何修复这个问题,以便在VS Code中连接? 英文:
I set up SSH on a remote machine & a local machine, with the intent of using VS Code SSH. I can connect to my remote with ssh
in the command line, but VS Code keeps dropping connections after successfully connecting with something like ssh child died, shutting down
.
Why can I connect via CLI SSH, but not VS Code? How do I fix this?
Background {#background}
- Setup
- Followed the instructions on Get started with OpenSSH for Windows and Key-based authentication in OpenSSH for Windows to set up initial SSH.
- Validation
ssh -l REDACTED\citelao citelao-machine -vvv
works just fine- I confirmed I'm using the OpenSSH
ssh-agent
(https://stackoverflow.com/questions/60819352/how-can-i-use-windows-built-in-openssh-ssh-agent-in-vs-code-instead-of-git-bas/60821774#60821774) - I turned on super-verbose logs on the server, but couldn't find anything suspicious (Starting OpenSSH server in Windows with debug messages enabled (-d))
- I tried increasing
ServerAliveInterval 60
andServerAliveCountMax 30
- I tried
PubkeyAuthentication no
andPasswordAuthentication yes
(and tried with pubkey authentication)
How do I fix this, so I can connect in VS Code?
答案1 {#1}
得分: 1
解决方法
禁用Remote.SSH: 使用本地服务器 (将remote.SSH.useLocalServer
设置为false
):
根据此GitHub问题中的Rob Lourens的说法:
> 您遇到了一些Windows SSH服务器版本的错误 :/
更多信息
来自该问题的相关日志(在修复问题后,我无法获取自己的日志):
[16:11:07.635] stderr> 已通过身份验证到 127.0.0.1 ([127.0.0.1]:22)。
[16:11:10.183] stderr> client_loop: 发送断开连接:连接被对等方重置
[16:11:10.244] > local-server-1> ssh 子进程已终止,正在关闭
[16:11:10.368] 本地服务器退出:0
// ...
client_loop: 发送断开连接:连接被对等方重置
local-server-1> ssh 子进程已终止,正在关闭
[16:11:10.370] 无法从服务器输出中解析远程端口
[16:11:10.374] 解析器错误:错误:
在 Function.Create (c:\Users\alros\.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:585789)
在 Object.t.handleInstallOutput (c:\Users\alros\.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:584441)
在 Object.e [作为 tryInstallWithLocalServer] (c:\Users\alros\.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:624908)
在 processTicksAndRejections (node:internal/process/task_queues:96:5)
在 async c:\Users\alros\.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:643945
在 async Object.t.withShowDetailsEvent (c:\Users\alros\.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:647692)
在 async c:\Users\alros\.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:623380
在 async b (c:\Users\alros\.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:619886)
在 async Object.t.resolveWithLocalServer (c:\Users\alros\.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:622995)
在 async Object.t.resolve (c:\Users\alros\.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:645302)
在 async c:\Users\alros\.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:722235
[16:11:10.380] ------
英文:
Solution {#solution}
Disable Remote.SSH: Use Local Server (set remote.SSH.useLocalServer
to false
):
Per Rob Lourens in this GitHub issue:
> You are hitting a bug with some versions of the windows ssh server :/
More information {#more-information}
Relevant logs from the issue (I couldn't get my own logs after fixing the issue):
[16:11:07.635] stderr> Authenticated to 127.0.0.1 ([127.0.0.1]:22).
[16:11:10.183] stderr> client_loop: send disconnect: Connection reset by peer
[16:11:10.244] > local-server-1> ssh child died, shutting down
[16:11:10.368] Local server exit: 0
// ...
client_loop: send disconnect: Connection reset by peer
local-server-1\> ssh child died, shutting down
`[16:11:10.370] Failed to parse remote port from server output
[16:11:10.374] Resolver error: Error:
at Function.Create (c:\Users\alros.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:585789)
at Object.t.handleInstallOutput (c:\Users\alros.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:584441)
at Object.e [as tryInstallWithLocalServer] (c:\Users\alros.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:624908)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async c:\Users\alros.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:643945
at async Object.t.withShowDetailsEvent (c:\Users\alros.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:647692)
at async c:\Users\alros.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:623380
at async b (c:\Users\alros.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:619886)
at async Object.t.resolveWithLocalServer (c:\Users\alros.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:622995)
at async Object.t.resolve (c:\Users\alros.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:645302)
at async c:\Users\alros.vscode-insiders\extensions\ms-vscode-remote.remote-ssh-0.79.2022040715\out\extension.js:1:722235
[16:11:10.380] ------
`