一直在用的是游戏本,太重了,
最近考研想练习代码,奈何远程工具不能打开idea
问度娘搞到了cscode哈哈哈哈哈
福福福福福福福福福福福福福福福福福福福福福福福福福
整活:
运行环境
ECS:阿里云
系统:centos8.0
code-server 版本:3.2.0
VSApp 版本:2.2
配置code-server
临时买了阿里云 28.5 元3月的学生机 (呜呜呜之前9.5一月的没了)
先到 GitHub 上面下载 code-server 然后传到服务器上,或者直接在服务器上执行命令:
wget https://github.com/cdr/code-server/releases/download/3.2.0/code-server-3.2.0-linux-x86_64.tar.gz
太长改个名
mv code-server-3.2.0-linux-x86_64 code-server
运行:
cd code-server
./code-server
推荐先看一遍参数表:
./code-server --help
显示类似于:
Usage: code-server [options] [path]
Options
--auth The type of authentication to use. [password, none]
--cert Path to certificate. Generated if no path is provided.
--cert-key Path to certificate key when using non-generated cert.
--disable-updates Disable automatic updates.
--disable-telemetry Disable telemetry.
-h --help Show this output.
--open Open in browser on startup. Does not work remotely.
--bind-addr Address to bind to in host:port.
--socket Path to a socket (bind-addr will be ignored).
-v --version Display version information.
--user-data-dir Path to the user data directory.
--extensions-dir Path to the extensions directory.
--list-extensions List installed VS Code extensions.
--force Avoid prompts when installing VS Code extensions.
--install-extension Install or update a VS Code extension by id or vsix.
--uninstall-extension Uninstall a VS Code extension by id.
--show-versions Show VS Code extension versions.
--proxy-domain Domain used for proxying ports.
-vvv --verbose Enable verbose logging.
常用的运行方式:
export PASSWORD="315315"
./code-server --port 9999 --host 0.0.0.0 --auth password
–port 9999 指定端口,缺省时为 8080
–host 0.0.0.0 允许公网访问,缺省时为 127.0.0.1,只能本地访问
–auth password 指定访问密码,可通过 export 命令设置,参数为 none 时不启用密码
显示类似于:
info code-server 3.2.0 fd36a99a4c78669970ebc4eb05768293b657716f
info HTTP server listening on http://0.0.0.0:9999
info - Using custom password for authentication
info - Not serving HTTPS
info Automatic updates are enabled
此时会话终止时 code-server 也随即终止,挂到后台运行:
nohup ./code-server --port 9999 --host 0.0.0.0 --auth password > test.log 2>&1 &
上面的命令执行后会返回一个 PID,结束运行只需要:
kill -9 PID
如果忘记保存 PID,查询方法:
ps aux | grep ./code-server
但是每次都打一长串代码不方便,写成bash文件:
#start.sh
export PASSWORD="114514"
nohup ./code-server --port 9999 --host 0.0.0.0 --auth password > test.log 2>&1 &
echo $! > save_pid.txt
#shut.sh
kill -9 'cat save_pid.txt'
到这里为止,已经可以用浏览器食用 code-server 了
配置VSApp
App Store 搜索 VSApp 安装,打开后可以选择开发者提供的服务器(付费),也可以用自己的。
这里当然选择 Self Hosted Server(不然为什么要折腾 code-server
依次填写:
code-server URL:服务器 IP :端口
Instance password:–auth 命令设置的密码
Host:服务器 IP
Username:登录用户名
Port:SSH 端口(默认 22)
Authentication:密码或密钥对(点击 Setup key pair 设置)
保存以后就可以用 VSApp 访问 code-server 了:
please!!!