code-server has the ability to secure your connection between client and server using SSL/TSL certificates. By default, the server will start with an unencrypted connection. We recommend Self-signed TLS/SSL certificates for personal use of code-server or within an organization.
This guide will show you how to create a self-signed certificate and start code-server using your certificate/key.
You can specify any location that you want to save the certificate and key. In this example, we will navigate to the root directory, create a folder called certs
and cd into it.
mkdir ~/certs && cd ~/certs
If you don't already have a TLS certificate and key, you can generate them with the command below. They will be placed in ~/certs
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ~/certs/MyKey.key -out ~/certs/MyCertificate.crt
You will be prompted to add some identifying information about your organization
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:TX
Locality Name (eg, city) []:Austin
Organization Name (eg, company) [Coder Technologies]:Coder
Organizational Unit Name (eg, section) []:Docs
Common Name (e.g. server FQDN or YOUR name) []:hostname.example.com
Email Address []:admin@example.com
If you already have a TLS certificate and key, you can simply reference them in the
--cert
and--cert-key
flags when launching code-server
./code-server --cert=~/certs/MyCertificate.crt --cert-key=~/certs/MyKey.key
You will know your connection is secure if the lines
WARN No certificate specified. This could be insecure. WARN Documentation on securing your setup: https://coder.com/docs
no longer appear.
For larger organizations you may wish to rely on a Certificate Authority as opposed to a self-signed certificate. For more information on generating free and open certificates for your site, please check out EFF's certbot. Certbot is a cli to generate certificates using LetsEncrypt.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。