vscode ssh connection failed

Use vscode ssh to connect to the linux server on windows, it can be used normally all the time, but suddenly the connection fails, report an error log

The reason is: vscode has updated itself, causing the files in ~/.vscode-server on the original server to expire. If the server is always connected to the external network, then vscode will download itself. If the server is not connected to the external network, it will appear In my case, the connection has been unsuccessful, and the following information has been reported incorrectly.

Solution:
1. Open the server network
2. Manually download the package and upload it to the server (see Chapter 2)
3. Use vscode to connect to the virtual machine. If the connection is successful, package ~/.vscode-server/bin/* in the virtual machine and put it on the server – recommended

[08:48:13.513] Server installation process already in progress - waiting and retrying
[08:48:14.517] Running script with connection command: ssh -T -D 58042 "192.168.31.235" bash
[08:48:14.518] Terminal shell path: C:\Windows\System32\cmd.exe
[08:48:14.900] > ]0;C:\Windows\System32\cmd.exe
[08:48:14.900] Got some output, clearing connection timeout
[08:48:14.933] "install" terminal command done
[08:48:14.933] Install terminal quit with output:
[08:48:15.404] > 741b6048ee5c: running
[08:48:15.469] > Acquiring lock on /home/zhangyasheng/.vscode-server/bin/c3f126316369cd610563c75b
> 1b1725e0679adfb3/vscode-remote-lock.zhangyasheng.c3f126316369cd610563c75b1b1725e
> 0679adfb3
[08:48:15.478] > Installation already in progress...
> If you continue to see this message, you can try toggling the remote.SSH.useFloc
> k setting
> 741b6048ee5c: start
> exitCode==24==
> listeningOn====
> osReleaseId==ubuntu==
> arch==x86_64==
> tmpDir==/run/user/1017==
> platform==linux==
> unpackResult====
> didLocalDownload==0==
> downloadTime====
> installTime====
> extInstallTime====
> serverStartTime====
> 741b6048ee5c: end
[08:48:15.478] Received install output:
exitCode==24==
listeningOn====
osReleaseId==ubuntu==
arch==x86_64==
tmpDir==/run/user/1017==
platform==linux==
unpackResult====
didLocalDownload==0==
downloadTime====
installTime====
extInstallTime====
serverStartTime====

[08:48:15.478] Server installation process already in progress - waiting and retrying
[08:48:16.481] Running script with connection command: ssh -T -D 58042 "192.168.31.235" bash
[08:48:16.482] Terminal shell path: C:\Windows\System32\cmd.exe
[08:48:16.862] > ]0;C:\Windows\System32\cmd.exe
[08:48:16.863] Got some output, clearing connection timeout
[08:48:16.899] "install" terminal command done
[08:48:16.900] Install terminal quit with output:
[08:48:17.397] > 741b6048ee5c: running
[08:48:17.459] > Acquiring lock on /home/zhangyasheng/.vscode-server/bin/c3f126316369cd610563c75b
> 1b1725e0679adfb3/vscode-remote-lock.zhangyasheng.c3f126316369cd610563c75b1b1725e
> 0679adfb3
[08:48:17.467] > Installation already in progress...
> If you continue to see this message, you can try toggling the remote.SSH.useFloc
> k setting
> 741b6048ee5c: start
> exitCode==24==
> listeningOn====
> osReleaseId==ubuntu==
> arch==x86_64==
> tmpDir==/run/user/1017==
> platform==linux==
> unpackResult====
> didLocalDownload==0==
> downloadTime====
> installTime====
> extInstallTime====
> serverStartTime====
> 741b6048ee5c: end
[08:48:17.468] Received install output:
exitCode==24==
listeningOn====
osReleaseId==ubuntu==
arch==x86_64==
tmpDir==/run/user/1017==
platform==linux==
unpackResult====
didLocalDownload==0==
downloadTime====
installTime====
extInstallTime====
serverStartTime====

1. Delete the locked file

rm -rf /home/zhangyasheng/.vscode-server/bin/c3f126316369cd6105

[09:14:19.014] Log Level: 2
[09:14:19.022] [email protected]
[09:14:19.022] win32 x64
[09:14:19.045] SSH Resolver called for "ssh-remote + 192.168.31.235", attempt 1
[09:14:19.046] "remote.SSH.useLocalServer": false
[09:14:19.046] "remote.SSH.showLoginTerminal": false
[09:14:19.046] "remote.SSH.remotePlatform": {<!-- -->"192.168.31.235":"linux","192.168.15.59":"linux ","192.168.31.190":"linux","192.168.31.237":"linux","192.168.15.207":"linux","192.168.15.210 ":"linux","10.192.76.131":"linux","192.168.15.20":"linux","192.168.15.157":"linux" }
[09:14:19.046] "remote.SSH.path": undefined
[09:14:19.047] "remote.SSH.configFile": undefined
[09:14:19.047] "remote.SSH.useFlock": true
[09:14:19.047] "remote.SSH.lockfilesInTmp": false
[09:14:19.047] "remote.SSH.localServerDownload": auto
[09:14:19.047] "remote.SSH.remoteServerListenOnSocket": false
[09:14:19.047] "remote.SSH.showLoginTerminal": false
[09:14:19.048] "remote.SSH.defaultExtensions": []
[09:14:19.048] "remote.SSH.loglevel": 2
[09:14:19.048] SSH Resolver called for host: 192.168.31.235
[09:14:19.048] Setting up SSH remote "192.168.31.235"
[09:14:19.079] Using commit id "c3f126316369cd610563c75b1b1725e0679adfb3" and quality "stable" for server
[09:14:19.081] Install and start server if needed
[09:14:19.086] Checking ssh with "ssh -V"
[09:14:19.227] > OpenSSH_for_Windows_8.
[09:14:19.227] > 1p1, LibreSSL 3.0.2

[09:14:19.232] Running script with connection command: ssh -T -D 56763 "192.168.31.235" bash
[09:14:19.234] Terminal shell path: C:\Windows\System32\cmd.exe
[09:14:19.567] > ]0;C:\Windows\System32\cmd.exe
[09:14:19.567] Got some output, clearing connection timeout
[09:14:20.120] > 90cd877ed6f4: running
[09:14:20.176] > Acquiring lock on /home/zhangyasheng/.vscode-server/bin/c3f126316369cd610563c75b
> 1b1725e0679adfb3/vscode-remote-lock.zhangyasheng.c3f126316369cd610563c75b1b1725e
> 0679adfb3
[09:14:20.194] > Installing to /home/zhangyasheng/.vscode-server/bin/c3f126316369cd610563c75b1b17
> 25e0679adfb3...
[09:14:20.202] > 90cd877ed6f4%%1%%
[09:14:20.211] > Downloading with wget
[09:14:27.225] > wget download failed
> Failed: Connection timed out.
> printenv:
[09:14:27.232] > LC_MEASUREMENT=zh_TW.UTF-8
> SSH_CONNECTION=192.168.31.111 56765 192.168.31.235 22
> LC_PAPER=zh_TW.UTF-8
> LC_MONETARY=zh_TW.UTF-8
> LANG=zh_CN.UTF-8
> LC_NAME=zh_TW.UTF-8
> XDG_SESSION_ID=32567
> USER=zhangyasheng
> PWD=/home/zhangyasheng/.vscode-server/bin/c3f126316369cd610563c75b1b1725e067
> 9adfb3
> HOME=/home/zhangyasheng
> SSH_CLIENT=192.168.31.111 56765 22
> LC_ADDRESS=zh_TW.UTF-8
> LC_NUMERIC=zh_TW.UTF-8
> MAIL=/var/mail/zhangyasheng
> SHELL=/bin/bash
> SHLVL=2
> LANGUAGE=zh_CN:zh
> LC_TELEPHONE=zh_TW.UTF-8
> VSCODE_AGENT_FOLDER=/home/zhangyasheng/.vscode-server
> LOGNAME=zhangyasheng
> DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1017/bus
> XDG_RUNTIME_DIR=/run/user/1017
> PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
> :/usr/local/games:/snap/bin
> LC_IDENTIFICATION=zh_TW.UTF-8
> LC_TIME=zh_TW.UTF-8
>_=/usr/bin/printenv
> OLDPWD=/home/zhangyasheng
> Trigger local server download
> 90cd877ed6f4:trigger_server_download
> platform==linux==
> vscodeArch==x64==
> destFolder==/home/zhangyasheng/.vscode-server/bin/c3f126316369cd610563c75b1b1725
>e0679adfb3==
> 90cd877ed6f4:trigger_server_download_end
> Waiting for client to transfer server archive...
> Waiting for /home/zhangyasheng/.vscode-server/bin/c3f126316369cd610563c75b1b1725
> e0679adfb3/vscode-scp-done.flag and vscode-server.tar.gz to exist
>
[09:14:27.233] Got request to download on client for {<!-- -->"platform":"linux","arch":"x64","destFolder\ ":"/home/zhangyasheng/.vscode-server/bin/c3f126316369cd610563c75b1b1725e0679adfb3"}
[09:14:27.233] Downloading VS Code server locally...
[09:14:27.509] Resolver error: Error: Running the contributed command: '_workbench.downloadResource' failed.
at S._executeContributedCommand (d:\software\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\\
ode\extensionHostProcess.js:84:120745)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async c:\Users\zys\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.7\out\extension.js:1:139384
at async Object.t.downloadAndCopyToHost (c:\Users\zys\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.7\out\extension.js:1:139299 )
at async c:\Users\zys\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.7\out\extension.js:1:414617
at async Object.t.tryInstall (c:\Users\zys\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.7\out\extension.js:1:414829 )
at async c:\Users\zys\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.7\out\extension.js:1:294918
at async Object.t.withShowDetailsEvent (c:\Users\zys\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.7\out\extension.js:1:406463 )
at async Object.t.resolve (c:\Users\zys\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.7\out\extension.js:1:295994 )
at async c:\Users\zys\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.7\out\extension.js:127:110656
[09:14:27.511] ------

2. What to download here

My server can’t access the external network, so I download it manually

  1. First delete the folder under ~/.vscode-server/bin/ to trigger wget
  2. Re-ssh with vscode
  3. When you see the vscode output download, check the process of the server
    ps -ef | grep vscode
    zhangya + 49922 0.0 0.0 42876 6468 ? S 09:43 0:00 wget –tries=1 –connect-timeout=7 –dns-timeout=7 -nv -O vscode-server.tar.gz https:// update.code.visualstudio.com/commit:c3f126316369cd610563c75b1b1725e0679adfb3/server-linux-x64/stable
https://update.code.visualstudio.com/commit:c3f126316369cd610563c75b1b1725e0679adfb3/server-linux-x64/stable
  1. Then unzip the downloaded package to the server ~/.vscode-server/bin/*/, note: there is a folder under bin, you need to enter it
  2. tar -vxzf vscode-server-linux-x64.tar.gz -C ./
  3. mv vscode-server-linux-x64/* .
  4. Then use vscode to connect

Turn off the automatic update of vscode