Local OS Version:
版本 Windows 10 家庭中文版
安装日期 2020-06-16
操作系统版本 19041.508
体验 Windows Feature Experience Pack 120.2212.31.0
Remote OS Version:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
Linux oasis 4.15.0-106-generic #107-Ubuntu SMP Thu Jun 4 11:27:52 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Linux version 4.15.0-106-generic (buildd@lcy01-amd64-016) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #107-Ubuntu SMP Thu Jun 4 11:27:52 UTC 2020
VSCode Version:
版本: 1.50.0升级为1.50.1 (user setup)
提交: d2e414d9e4239a252d1ab117bd7067f125afd80a
日期: 2020-10-13T15:06:15.712Z
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.19041
插件remote-ssh版本
v0.55.0
vscode远程设置
配置文件: C:\Users\XXW.ssh\vastai_id_rsa\config
内容:
Host 111HostName 192.168.6.240IdentityFile C:\Users\XXW\.ssh\vastai_id_rsaUser kevinxPort 22IdentitiesOnly yesHost 222IdentityFile C:\Users\XXW\.ssh\vastai_id_rsaHostName 192.168.50.114User xxwPort 22IdentitiesOnly yes
问题描述:
通过vscode,远程连接222,一切正常。
通过vscode,远程连接111,多次尝试连接,最后连接失败。如下:

有时候提示这样的
[10:58:10.251] Received install output: d5db649fd3c2##24##[10:58:10.251] Server installation process already in progress - waiting and retrying[10:58:10.545] "install" terminal command done[10:58:10.546] Install terminal quit with output:[10:58:11.268] Using SSH config file "C:\Users\XXW\.ssh\config"[10:58:11.269] Running script with connection command: ssh -T -D 56593 -F "C:\Users\XXW\.ssh\config" 111 bash[10:58:11.272] Terminal shell path: C:\WINDOWS\System32\cmd.exe[10:58:13.396] "install" terminal received data: "[2J[m[Hd5db649fd3c2: running]0;C:\WINDOWS\System32\cmd.exe[?25h"[10:58:13.397] Got some output, clearing connection timeout[10:58:13.711] "install" terminal command done[10:58:13.712] Install terminal quit with output: ]0;C:\WINDOWS\System32\cmd.exe[10:58:13.712] Received install output: ]0;C:\WINDOWS\System32\cmd.exe[10:58:13.713] Stopped parsing output early. Remaining text: ]0;C:\WINDOWS\System32\cmd.exe[10:58:13.713] Failed to parse remote port from server output[10:58:13.721] Resolver error: Error:at Function.Create (c:\Users\XXW\.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:1:130564)at Object.t.handleInstallOutput (c:\Users\XXW\.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:1:127671)at I (c:\Users\XXW\.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:106775)at processTicksAndRejections (internal/process/task_queues.js:94:5)at async c:\Users\XXW\.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:104774at async Object.t.withShowDetailsEvent (c:\Users\XXW\.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:109845)at async Object.t.resolve (c:\Users\XXW\.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:107960)at async c:\Users\XXW\.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:141955[10:58:13.725] TELEMETRY: {"eventName":"resolver","properties":{"outcome":"failure","reason":"UnparsableOutput","askedPw":"0","askedPassphrase":"0","asked2fa":"0","askedHostKey":"0","gotUnrecognizedPrompt":"0","remoteInConfigFile":"1"},"measures":{"resolveAttempts":1,"retries":4}}[10:58:13.728] ------
或者这样的提示:
[08:59:34.313] > Found running server...[08:59:34.320] >> *> * Reminder: You may only use this software with Visual Studio family products,> * as described in the license (https://go.microsoft.com/fwlink/?linkid=2077057)> *>> Checking server status on port 35179 with wget> failed: Connection refused.> 47b9d415b0c4##28##[08:59:34.320] Received install output: 47b9d415b0c4##28##[08:59:34.320] Server status check failed - waiting and retrying[08:59:34.623] "install" terminal command done[08:59:34.624] Install terminal quit with output:[08:59:35.334] Resolver error: Error:at Function.Create (c:\Users\XXW\.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:1:130564)at c:\Users\XXW\.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:105225at async Object.t.withShowDetailsEvent (c:\Users\XXW\.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:109845)at async Object.t.resolve (c:\Users\XXW\.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:107960)at async c:\Users\XXW\.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:141955[08:59:35.339] ------
备注:
1 用别的终端(例如cmd, MobaXterm),可以正常访问111
2 用vscode 可以正常访问其它的服务器222.
尝试解决方法:
1 将本地的ssh pub秘钥中的内容替换远程服务器的.ssh目录下的authorized_keys,重启。结果还是无法连接。
无效
2 将本地文件 known_hosts 的内容清空
参考 https://blog.csdn.net/weixin_42902669/article/details/106334059
无效
3 修改设置:”remote.SSH.useLocalServer”: false,
参考 https://segmentfault.com/q/1010000022940805
无效
4 安装其它版本的vscode,
无效
5 安装其它版本remote-ssh插件
无效
6
通过前面的观察和总结,可以得出问题一定出现在111服务器端的vscode-server
- 用别的终端(例如cmd, MobaXterm),可以正常访问111服务器。-> 表示该服务器的ssh server没有问题
- 用vscode 可以正常访问其它的服务器222. -> 表示本地安装的vscode没有问题
- 那么,只有一种可能,即111服务器上的vscode-server有问题。
删除远程服务器上的 .vscode-server文件夹 : “rm -fr ~/.vscode-server“
然后启动vscode, 重新连接111服务器,111服务器会自动下载和安装vscode server,连接成功!!!
后续:
经过测试发现,vscode版本从1.50.0更新到1.50.1之后,如果在不同的客户端通过vscode用同一个账户访问同一台远程服务器(例如本例中的111),就会出现上面的问题。
解决办法:不用删除整个.vscode-server文件夹,只需要删除该文件夹下面的所有的日志文件即可(.log)。不过,比较麻烦的是,每次切换不同的客户端来访问111时,都需要实现删除.vscode-server文件夹下的log文件。**
通过log文件发现,对于不同的客户端,server监听的端口号都不一样:
例如pc1访问后的server上的log是:
** Visual Studio Code Server** Reminder: You may only use this software with Visual Studio family products,* as described in the license https://aka.ms/vscode-remote/license*IP Address: 192.168.6.240Extension host agent listening on 41483[23:51:13] Extension host agent started.[23:51:17] [127.0.0.1][19238420][ManagementConnection] New connection established.[23:51:17] [127.0.0.1][a3a87239][ExtensionHostConnection] New connection established.bash: cannot set terminal process group (-1): Inappropriate ioctl for devicebash: no job control in this shell[23:51:18] [127.0.0.1][a3a87239][ExtensionHostConnection] <46890> Launched Extension Host Process.[23:52:26] [127.0.0.1][19238420][ManagementConnection] The client has disconnected gracefully, so the connection will be disposed.[23:52:27] [127.0.0.1][a3a87239][ExtensionHostConnection] <46890> Extension Host Process exited with code: 0, signal: null.Last EH closed, waiting before shutting down[23:52:27] Last EH closed, waiting before shutting downLast EH closed, shutting down[23:57:27] Last EH closed, shutting down
而pc2访问后的server上的log是:
** Visual Studio Code Server** Reminder: You may only use this software with Visual Studio family products,* as described in the license https://aka.ms/vscode-remote/license*IP Address: 192.168.6.240Extension host agent listening on 34651[08:47:54] Extension host agent started.[08:47:58] [127.0.0.1][22513247][ManagementConnection] New connection established.[08:47:58] [127.0.0.1][8560fc28][ExtensionHostConnection] New connection established.bash: cannot set terminal process group (-1): Inappropriate ioctl for devicebash: no job control in this shell[08:47:59] [127.0.0.1][8560fc28][ExtensionHostConnection] <33882> Launched Extension Host Process.[08:48:03] Installing extension: cschlosser.doxdocgen[08:48:04] Downloaded extension: cschlosser.doxdocgen undefined[08:48:05] Extracted extension to /home/VASTAI/kevinx/.vscode-server/extensions/.cschlosser.doxdocgen-1.1.0: cschlosser.doxdocgen[08:48:05] Renamed to /home/VASTAI/kevinx/.vscode-server/extensions/cschlosser.doxdocgen-1.1.0[08:48:05] Installation completed. cschlosser.doxdocgen[08:48:05] Extensions installed successfully: cschlosser.doxdocgen[08:48:51] [127.0.0.1][22513247][ManagementConnection] The client has disconnected gracefully, so the connection will be disposed.[08:48:52] [127.0.0.1][8560fc28][ExtensionHostConnection] <33882> Extension Host Process exited with code: 0, signal: null.Last EH closed, waiting before shutting down[08:48:52] Last EH closed, waiting before shutting down
pc1对应的是41483, pc2对应的34651(只要中间没有切换client,就会保持不变)。如果pc1正常访问后退出,pc2再访问,log中所对应的端口号不一致,所以会导致连接错误。这时,删除log文件,重新连接,就会重新生成新的log,端口号就是当前pc2的端口号(当然也是重新生成的),当然就正常连接了。
