VS Code 连接 Remote SSH 一直卡在 "Downloading VS Code Server" 的解决方案
在使用 VS Code 的 Remote SSH
插件连接服务器时,经常会遇到进度条一直卡在
Downloading VS Code Server
的情况。经过排查,这种情况通常由以下两种原因导致:
- 网络问题:VS Code Server 确实没有下载成功。
- 插件 Bug:VS Code Server 下载成功了,但新版 Remote SSH 插件存在 Bug,导致一直卡顿。
情况一:下载失败
通常是因为本地或服务器网络连接外网不畅导致的。
解决方案:
* 检查版本:确保你的 VS Code 和 Remote SSH
插件不是非常老旧的版本。
*
检查网络:保证你的本机(Client)是可以正常连接外网的。
原理说明:
旧版的 Remote SSH 尝试直接从服务器端下载 Server 组件;而新版的 Remote
SSH 在服务器下载失败后,会尝试从本机下载,然后通过
scp
传输到服务器上。因此,只要本机网络正常且软件版本较新,通常能自动解决此问题。
情况二:新版插件 Bug(重点)
如果你已经确保了网络通畅且软件是最新的,但依然卡在下载界面,那么极有可能是遇到了 新版 Remote SSH 的 Bug。
这也是我遇到的情况,我的环境配置如下:
* VS Code 版本: 1.107.1
* Server OS: Ubuntu 20.04
* Client OS: macOS
问题描述:
本来是可以正常连接服务器的,但在手贱升级了 Remote SSH
插件后,连接过程就一直卡在 Downloading VS Code Server。
解决方案:版本回退
经过测试,最新版的 0.122.0
无法连接服务器,需要将插件回退到旧版本。
- 推荐版本:
0.100.0 - 操作方法:在 VS Code 插件市场中找到 Remote -
SSH,点击“卸载”旁边的小箭头(或右键),选择“安装另一个版本”,选择
0.100.0即可解决问题。
如果你安装不上插件,可以从这里下载并手动安装(下载后改后缀为.vsix):
后记
在本人解决该问题后,发现有人提出过这个问题:
https://stackoverflow.com/questions/77066938/remote-ssh-connection-hangs-at-downloading-vscode-server-step-after-updating-v
The newest VSCode version does not play nice with the most recent version of the "Remote SSH" extension due to a bug. It is being tracked here though it seems like it mostly ocurrs when the remote machine you're connecting to does not have an internet connection. While this is being fixed you could try
- setting "remote.SSH.useExecServer": false in settings.json or toggle the "Use Exec Server" checkbox in the settings
or- Downgrade VSCode and the "Remote SSH" extension to an older version