windows上使用vscode ssh连接到linux服务器,一直可以正常使用,但是突然就连接失败了,报错一下log
原因是:vscode自己更新了,导致原有的服务器上~/.vscode-server中的文件过期了,如果服务器一直连接外网的,那么vscode会自己下载,如果服务器没有连接外网,就出现了我的情况,一直连接不成功,一直报错下面的信息。
解决方法: 1. 打开服务器网络 2. 手动去下载包上传到服务器(见第二章节) 3. 使用vscode连接虚拟机,如果连接成功,把虚拟机中的~/.vscode-server/bin/* 打包放到服务器上 — 推荐
[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. 删掉上面加锁的文件
rm -rf /home/zhangyasheng/.vscode-server/bin/c3f126316369cd6105
[09:14:19.014] Log Level: 2
[09:14:19.022] remote-ssh@0.65.7
[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
> 失败:连接超时。
> 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\node\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.这里要去下载什么东西
我服务器端无法访问外网,所以我手动下载
- 先把~/.vscode-server/bin/下面的文件夹删掉,以触发wget
- 用vscode重新ssh
- 看到vscode输出download的时候,查看服务器的进程
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
- 然后把下载的包解压到服务器~/.vscode-server/bin/*/ , 注意:bin下有一个文件夹,要进去
- tar -vxzf vscode-server-linux-x64.tar.gz -C ./
- mv vscode-server-linux-x64/* .
- 再用vscode连接即可
关闭vscode的自动更新
|