1、安装visual studio code忽略,
2、按照如图所示添加ubuntu主机IP、用户
鼠标放在IP地址上面右键如下图:
3、点击上图中的“Connect to Host in current window”后会出现下面的信息
linux@192.168.3.37's password:
2bcac52f48d0: running
Acquiring lock on /home/linux/.vscode-server/bin/c3f126316369cd610563c75b1b1725e0679adfb3/vscode-remote-lock.linux.c3f126316369cd610563c75b1b1725e0679adfb3
Found existing installation at /home/linux/.vscode-server/bin/c3f126316369cd610563c75b1b1725e0679adfb3...
Checking /home/linux/.vscode-server/.c3f126316369cd610563c75b1b1725e0679adfb3.log and /home/linux/.vscode-server/.c3f126316369cd610563c75b1b1725e0679adfb3.pid for a running server
Starting server with command... /home/linux/.vscode-server/bin/c3f126316369cd610563c75b1b1725e0679adfb3/server.sh --start-server --host=127.0.0.1 --enable-remote-auto-shutdown --port=0 &> "/home/linux/.vscode-server/.c3f126316369cd610563c75b1b1725e0679adfb3.log" < /dev/null
printenv:
SHELL=/bin/bash
XDG_SESSION_COOKIE=1ef0a58a352d7d9e80d30e4500000003-1626882160.976378-1293310083
SSH_CLIENT=192.168.3.19 61305 22
USER=linux
VSCODE_AGENT_FOLDER=/home/linux/.vscode-server
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
MAIL=/var/mail/linux
PWD=/home/linux
LANG=zh_CN.UTF-8
HOME=/home/linux
SHLVL=2
LANGUAGE=zh_CN:zh
LOGNAME=linux
SSH_CONNECTION=192.168.3.19 61305 192.168.3.37 22
_=/usr/bin/printenv
Waiting for server log...
Waiting for server log...
Waiting for server log...
*
* Reminder: You may only use this software with Visual Studio family products,
* as described in the license (https://go.microsoft.com/fwlink/?linkid=2077057)
*
2bcac52f48d0: start
SSH_AUTH_SOCK====
DISPLAY====
webUiAccessToken====
listeningOn==52910==
osReleaseId==ubuntu==
arch==x86_64==
tmpDir==/tmp==
platform==linux==
unpackResult====
didLocalDownload==0==
downloadTime====
installTime====
extInstallTime====
serverStartTime==132==
connectionToken==eea0f0fd-d5ba-4e9c-b1b4-e87ea8d3b813==
2bcac52f48d0: end
1)如果出现问题首先删除:“C:\Users\lm.ssh\known_hosts”文件
2)提取出commit:xxx中的xxx
3)把2)中的xxx替换替换如下的xxx,根据不同的版本下载
vscode版本为insider
https://update.code.visualstudio.com/commit:xxxx/server-linux-x64/insider
vscode版本为stable
https://update.code.visualstudio.com/commit:c3f126316369cd610563c75b1b1725e0679adfb3/server-linux-x64/stable
4)下载后把“vscode-server-linux-x64.tar.gz”解压到ubuntu主机中如下文件夹
/home/ubuntu/.vscode-server/bin/c3f126316369cd610563c75b1b1725e0679adfb3