赞
踩
安装Code-Server的主要是为了远程协作更加方便,编译机和OA机之间通过远程桌面使用,会比较卡顿,而VSCode自身的ssh工具,使用起来总是不够顺手。直到遇到了由Coder开发的Code-Server, 基本可以和VSCode无缝切换,各种插件,主题基本都能直接使用,上手难度为0.
本人编译机环境介绍:
- [15:31:32 (48) jacob@jacob-hp code-server] $ lsb_release -a
- No LSB modules are available.
- Distributor ID: Ubuntu
- Description: Ubuntu 20.04.6 LTS
- Release: 20.04
- Codename: focal
- [15:31:45 (49) jacob@jacob-hp code-server] $ uname -a
- Linux jacob-hp 5.15.0-94-generic #104~20.04.1-Ubuntu SMP Tue Jan 16 13:34:09 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
(1)Coder官网: Coder | Cloud Development Environment: Remote & Self Hosted
(2)Code-Server: Home - code-server Docs
(1)使用脚本的方式进行安装
- 1、如果需要预览安装过程中会出现的异常,使用如下命令
- curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run
- 2、如果不关注安装过程,使用如下命令:
- curl -fsSL https://code-server.dev/install.sh | sh
- 3、可以使用如下命令仅下载安装脚本,然后手动执行脚本进行安装:
- curl -fsSL https://code-server.dev/install.sh -o code-server-install.sh
-
- 该脚本有以下参数可以使用,根据需要修改即可:
- --dry-run: echo the commands for the install process without running them.
- --method: choose the installation method.
- --method=detect: detect the package manager but fallback to --method=standalone.
- --method=standalone: install a standalone release archive into ~/.local.
- --prefix=/usr/local: install a standalone release archive system-wide.
- --version=X.X.X: install version X.X.X instead of latest version.
- --help: see usage docs.
- --edge: install the latest edge version (i.e. pre-release)

(2)直接下载github上的release包:
https://github.com/coder/code-server/releaseshttps://github.com/coder/code-server/releases
- export VERSION=4.23.1
- curl -fOL https://github.com/coder/code-server/releases/download/v$VERSION/code-server_${VERSION}_amd64.deb
- sudo dpkg -i code-server_${VERSION}_amd64.deb
(1)执行如下命令,可以在开机的时候启动:
sudo systemctl enable --now code-server@$USER
(2)修改配置文件, 配置文件路径:~/.config/code-server/config.yaml
bind-addr: 可以修改port为需要的port
auth: 可以指定为password或者none
password:如果auth为password, 需要设置password, 也支持Argon2加密的密码, 这两个二选一即可
- bind-addr: 0.0.0.0:28080
- auth: password
- # password: 123456
- hashed-password: $argon2i$v=19$m=16,t=2,p=2$eVYwb1VGMjRoQWNwNVpGMw$gjQJtCekg0w0JEoqqrrBmA
- cert: false
Argon2在线加密:Argon2 Hash Generator, Validator & Verifier
以234567为明文加密:
(a)在Plain Text Input下面的框输入自己的密码
(b)点击Salt下方框里面的齿轮,会随机生成一串字符串, 其他信息根据自己需要修改
(c)点击最下方的'GENERATE HASH'的按钮,会生成两种不同格式的密文, 选择Encoded类型的密文copy到配置文件里面
(3)在/usr/lib/code-server/lib/vscode/product.json里面加入如下内容, 可以使用VSCode的插件市场
- "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": ""
- }
到此,部署完成,code-server还有其他参数,可以根据需要自行了解和配置
在任意浏览器输入部署code-server的机器的ip(在本机可以直接使用127.0.0.1)及对应的port, 然后会要求输入密码,密码校验之后就会进入欢迎页面,可以按照自己的喜好进行配置
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。