31 C
Senior Writer and partner

How to install Code Server on Ubuntu 20.04?

With each passing day, the cloud is hosting more and more things. And it is also possible to host our IDE on a server and be able to use it from anywhere. To do this you need to learn how to install Code Server on Ubuntu 20.04

Code is an advanced text editor for application development. It is owned by Microsoft but we can use it without problems in any Linux distribution including the popular Ubuntu and Debian.

So as you read, we can have the power of Code on our server and be accessible from any computer with Internet.

We already showed you how to install Code on Ubuntu 20.04 now you can do it on a server.

- Advertisement -

Let’s start

Install Code Server on Ubuntu 20.04

First of all, access via SSH to your server. When doing so, make sure Ubuntu is fully up to date.

sudo apt update
sudo apt upgrade

The whole installation is made quite easy to do thanks to an installation script that will download and install the package for your distribution. In addition to this, it will create all the necessary directory structure along with its initial configuration files.

To download and run the Code Server installation script, run

sudo curl -fsSL https://code-server.dev/install.sh | sh

At the end you will be shown an output screen similar to this:

To have systemd start code-server now and restart on boot:
  sudo systemctl enable --now code-server@$USER
Or, if you don't want/need a background service you can run:

It is most convenient to run Code Server as a system service, so enable it to start with the system.

systemctl --user enable --now code-server
● code-server.service - code-server
     Loaded: loaded (/usr/lib/systemd/user/code-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2021-04-18 16:42:12 CEST; 17s ago
   Main PID: 1429 (node)
     CGroup: /user.slice/user-1000.slice/[email protected]/code-server.service
             ├─1429 /usr/lib/code-server/lib/node /usr/lib/code-server
             └─1447 /usr/lib/code-server/lib/node /usr/lib/code-server

Apr 18 16:42:12 osradar systemd[819]: Starting code-server...
Apr 18 16:42:12 osradar systemd[819]: Started code-server.
Apr 18 16:42:13 osradar code-server[1429]: [2021-04-18T14:42:13.189Z] info  Wrote default config file to ~/.config/code-server/config.yaml
Apr 18 16:42:13 osradar code-server[1447]: [2021-04-18T14:42:13.717Z] info  code-server 3.9.3 fe2dc2deb08e378069891b622bb62ad1d261d1b1
Apr 18 16:42:13 osradar code-server[1447]: [2021-04-18T14:42:13.718Z] info  Using user-data-dir ~/.local/share/code-server
Apr 18 16:42:13 osradar code-server[1447]: [2021-04-18T14:42:13.740Z] info  Using config file ~/.config/code-server/config.yaml
Apr 18 16:42:13 osradar code-server[1447]: [2021-04-18T14:42:13.740Z] info  HTTP server listening on
Apr 18 16:42:13 osradar code-server[1447]: [2021-04-18T14:42:13.740Z] info    - Authentication is enabled
Apr 18 16:42:13 osradar code-server[1447]: [2021-04-18T14:42:13.740Z] info      - Using password from ~/.config/code-server/config.yaml
Apr 18 16:42:13 osradar code-server[1447]: [2021-04-18T14:42:13.740Z] info    - Not serving HTTPS

This command also starts the service so we can check the status of the service by running.

Also, we can check the initial settings in the config.yaml file.

nano ~/.config/code-server/config.yaml
 auth: password
 password: 354d3026a4e594dbcc049b74
 cert: false

Optional: Configuring Nginx as the reverse proxy for Code Server

Although not mandatory, it is recommended to install Nginx and configure it as the Reverse Proxy for Code Server. The process is quite simple, first install it.

sudo apt install nginx

Then, create a ServerBlock file dedicated to Code Server.

sudo nano /etc/nginx/sites-available/codeserver

And add the following content:

server {
  listen 80 default_server;
  listen [::]:80 default_server;
  server_name _;
  location / {
        proxy_pass http://code-server;
    		proxy_http_version 1.1;
		    proxy_set_header Upgrade $http_upgrade;
    		proxy_set_header Connection "Upgrade";
		    proxy_set_header Host $host;

Then enable the ServerBlock and restart the service to apply the changes.

sudo ln -s /etc/nginx/sites-available/codeserver /etc/nginx/sites-enabled/codeserver

sudo systemctl reload nginx

It is also recommended to enable HTTPS by installing Let’s Encrypt certificates.

So, install the certbot package and python3-certbot-nginx.

sudo apt-get install certbot python3-certbot-nginx

And install the certificates by running

sudo certbot --nginx

During the execution of the command, you will be asked for your email, if you accept the license terms and your domain.

After finishing the process, restart Nginx.

sudo systemctl reload nginx

Testing Code Server

Now open a web browser and access https://your-domain and you will see the login screen.

1.- Welcome to Code Server screen
1.- Welcome to Code Server screen

Enter the password that is in the config.yaml file we opened recently.

And then you will be able to use the Code Server without any problems.

2.- Code Server on Ubuntu 20.04
2.- Code Server on Ubuntu 20.04


Code Server allows us to have all the power of Code in the cloud and be accessible from anywhere. This makes it interesting for many people and professional environments.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"


Please enter your comment!
Please enter your name here

Latest article