打开终端日志信息会发现以下错误:
Updating VS Code Server to version da15b6fd3ef856477bf6f4fb29ba1b7af717770d Removing previous installation... Installing VS Code Server for x64 (da15b6fd3ef856477bf6f4fb29ba1b7af717770d) Downloading: 100% /usr/bin/gzip: 1: ?ELF?ELF????: not found /usr/bin/gzip: 3: ???: not found /usr/bin/gzip: 4: Syntax error: "(" unexpected tar: Child returned status 2 tar: Error is not recoverable: exiting now tar is unable to read /home/deradmin/.vscode-server/bin/da15b6fd3ef856477bf6f4fb29ba1b7af717770d-1652216065.tar.gz. Either the file is corrupt or tar has an issue. There's a known WSL issue with tar on Ubuntu 19.10. See workaround in #1856. Reload the window to initiate a new server download.
导致原因是WSL版本问题,需要从WSL1切换到WSL2.解决方案如下:
1.切换版本参考链接:
wsl -l -v wsl --set-default-version 2 wsl --set-version Ubuntu-22.04 2 #will set your Ubuntu 22.04 distribution to use WSL 2
下载地址:Manual installation steps for older versions of WSL | Microsoft Docs
net stop LxssManager net start LxssManager
4、在ubuntu系统中启动ssh服务,vscode中的remote-ssh即可连接上