当前位置:   article > 正文

Code-Server 安装部署教程, 可以在网页中使用的VSCode_code-server部署

code-server部署

一、Code-Server

        安装Code-Server的主要是为了远程协作更加方便,编译机和OA机之间通过远程桌面使用,会比较卡顿,而VSCode自身的ssh工具,使用起来总是不够顺手。直到遇到了由Coder开发的Code-Server, 基本可以和VSCode无缝切换,各种插件,主题基本都能直接使用,上手难度为0.

        本人编译机环境介绍:

  1. [15:31:32 (48) jacob@jacob-hp code-server] $ lsb_release -a
  2. No LSB modules are available.
  3. Distributor ID: Ubuntu
  4. Description: Ubuntu 20.04.6 LTS
  5. Release: 20.04
  6. Codename: focal
  7. [15:31:45 (49) jacob@jacob-hp code-server] $ uname -a
  8. 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、官网 

                (1)Coder官网: Coder | Cloud Development Environment: Remote & Self Hosted

                (2)Code-Server: Home - code-server Docs

        2、安装方式

                (1)使用脚本的方式进行安装

  1. 1、如果需要预览安装过程中会出现的异常,使用如下命令
  2. curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run
  3. 2、如果不关注安装过程,使用如下命令:
  4. curl -fsSL https://code-server.dev/install.sh | sh
  5. 3、可以使用如下命令仅下载安装脚本,然后手动执行脚本进行安装:
  6. curl -fsSL https://code-server.dev/install.sh -o code-server-install.sh
  7. 该脚本有以下参数可以使用,根据需要修改即可:
  8. --dry-run: echo the commands for the install process without running them.
  9. --method: choose the installation method.
  10. --method=detect: detect the package manager but fallback to --method=standalone.
  11. --method=standalone: install a standalone release archive into ~/.local.
  12. --prefix=/usr/local: install a standalone release archive system-wide.
  13. --version=X.X.X: install version X.X.X instead of latest version.
  14. --help: see usage docs.
  15. --edge: install the latest edge version (i.e. pre-release)

                (2)直接下载github上的release包:
https://github.com/coder/code-server/releasesicon-default.png?t=N7T8https://github.com/coder/code-server/releases

  1. export VERSION=4.23.1
  2. curl -fOL https://github.com/coder/code-server/releases/download/v$VERSION/code-server_${VERSION}_amd64.deb
  3. sudo dpkg -i code-server_${VERSION}_amd64.deb

        3、环境部署

                (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加密的密码, 这两个二选一即可

  1. bind-addr: 0.0.0.0:28080
  2. auth: password
  3. # password: 123456
  4. hashed-password: $argon2i$v=19$m=16,t=2,p=2$eVYwb1VGMjRoQWNwNVpGMw$gjQJtCekg0w0JEoqqrrBmA
  5. 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的插件市场

  1. "extensionsGallery": {
  2. "serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery",
  3. "cacheUrl": "https://vscode.blob.core.windows.net/gallery/index",
  4. "itemUrl": "https://marketplace.visualstudio.com/items",
  5. "controlUrl": "",
  6. "recommendationsUrl": ""
  7. }

        到此,部署完成,code-server还有其他参数,可以根据需要自行了解和配置

三、使用教程

        在任意浏览器输入部署code-server的机器的ip(在本机可以直接使用127.0.0.1)及对应的port, 然后会要求输入密码,密码校验之后就会进入欢迎页面,可以按照自己的喜好进行配置

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/732228
推荐阅读
相关标签
  

闽ICP备14008679号