1. 找到vs code的提交版本号:
打开远端项目时会显示setting up: downloading vs code server 之类的提示,这时在远端执行
ps aux | grep wget
可以看到
wget --tries=0 --connect-timeout=7 --dns-timeout=7 --show-progress -nv -O vscode-server.tar.gz http://update.code.visualstudio.com/commit:b3318bc0524af3d74034b8bb8a64df0ccf35549a/server-linux-x64/stable
2. 找到真正的下载地址, 将上面的wget 移除-nv
wget --tries=0 --connect-timeout=7 --dns-timeout=7 --show-progress -O vscode-server.tar.gz http://update.code.visualstudio.com/commit:b3318bc0524af3d74034b8bb8a64df0ccf35549a/server-linux-x64/stable
URL transformed to HTTPS due to an HSTS policy
--2021-11-08 15:57:26-- https://update.code.visualstudio.com/commit:b3318bc0524af3d74034b8bb8a64df0ccf35549a/server-linux-x64/stable
Resolving update.code.visualstudio.com (update.code.visualstudio.com)... 20.43.132.130
Connecting to update.code.visualstudio.com (update.code.visualstudio.com)|20.43.132.130|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://az764295.vo.msecnd.net/stable/b3318bc0524af3d74034b8bb8a64df0ccf35549a/vscode-server-linux-x64.tar.gz [following]
--2021-11-08 15:57:26-- https://az764295.vo.msecnd.net/stable/b3318bc0524af3d74034b8bb8a64df0ccf35549a/vscode-server-linux-x64.tar.gz
Resolving az764295.vo.msecnd.net (az764295.vo.msecnd.net)... 117.18.232.200
Connecting to az764295.vo.msecnd.net (az764295.vo.msecnd.net)|117.18.232.200|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 53650674 (51M) [application/gzip]
Saving to: ‘vscode-server.tar.gz’
3. 使用vscode.cdn.azure.cn取代az764295.vo.msecnd.net
wget --tries=0 --connect-timeout=7 --dns-timeout=7 --show-progress -O vscode-server.tar.gz https://vscode.cdn.azure.cn/stable/b3318bc0524af3d74034b8bb8a64df0ccf35549a/vscode-server-linux-x64.tar.gz
替换后的下载速度大概为1.72MB/s, 比原来的2kb/s快了几百倍。
4. 将下载的文件放入~/.vscode-server/bin/b3318bc0524af3d74034b8bb8a64df0ccf35549a
5. 解压
tar xf vscode-server.tar.gz
6. 移动一级目录到上层
mv vscode-server-linux-x64/* .