安装
下载 : https://github.com/coder/code-server/releases
1
| sudo apt install ./code-server-xxx.deb
|
配置
~/.config/code-server/config.yaml
:
1 2 3 4 5
| bind-addr: 127.0.0.1:8080 auth: password password: xxxxx cert: false
|
使用
1 2
| screen -R code-server code-server
|
之后在client端ssh转发远程端口到本地:
1
| ssh -N -L 8080:127.0.0.1:8080 usr@x.x.x.x -p [port]
|
在浏览器打开http://127.0.0.1:8080
即可
使用 vscode 原生插件市场地址
Ubuntu上deb安装后code-server 将插件市场地址切换到微软源,仅需 替换/添加 下面文件的对应内容
文件:
/usr/lib/code-server/lib/vscode/product.json
添加内容:
1 2 3 4 5 6 7
| "extensionsGallery": { "serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery", "cacheUrl": "https://vscode.blob.core.windows.net/gallery/index", "itemUrl": "https://marketplace.visualstudio.com/items", "controlUrl": "", "recommendationsUrl": "" }
|
一个脚本:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| import json
config_file = "/usr/lib/code-server/lib/vscode/product.json"
with open(config_file, "r", encoding="utf-8") as f: config = json.load(f)
config["extensionsGallery"] = { "serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery", "cacheUrl": "https://vscode.blob.core.windows.net/gallery/index", "itemUrl": "https://marketplace.visualstudio.com/items", "controlUrl": "", "recommendationsUrl": "", }
with open(config_file, "w", encoding="utf-8") as f: json.dump(config, f, indent=4)
|
复用vscode remote的extension (不建议)
1
| code-server --user-data-dir ~/.vscode-server
|