In this tutorial, we'll guide you through setting up Visual Studio Code Server (code-server) on a remote server, enabling you to access your development environment from any device with a browser. Running code-server on a remote server provides consistent access to your code and tools, offloads processing from your local device, and allows for collaboration. By the end of this guide, you will have code-server installed as a service, accessible via SSH and IP, ensuring your environment is always available and easily manageable.
First, ensure your server’s package list is up-to-date:
sudo apt updateIf OpenSSH is not installed, install it to allow remote access:
sudo apt install openssh-serverEnable and start the SSH service to ensure it is active:
sudo systemctl start ssh
sudo systemctl enable sshDownload and install `code-server` using the install script:
sudo apt install curl
curl -fsSL https://code-server.dev/install.sh | sh
sudo systemctl enable --now code-server@$USEROnce installed, configure `code-server` by editing its config file. Open it with:
nano ~/.config/code-server/config.yamlSet a password (optional) and specify the host and port as shown:
password: "your_password"
bind-addr: 0.0.0.0:8080Set up `code-server` to start automatically by creating a systemd service:
sudo nano /etc/systemd/system/code-server.serviceAdd the following configuration:
[Unit]
Description=code-server
After=network.target
[Service]
ExecStart=/usr/bin/code-server --host 0.0.0.0 --port 8080
User=your_username
Restart=always
[Install]
WantedBy=multi-user.targetEnable the service to start on boot, then start it:
sudo systemctl enable code-server
sudo systemctl start code-serverIf you are using a firewall, allow traffic to port 8080 (or the port configured in `config.yaml`):
sudo ufw allow 8080Open your web browser and go to:
http://your_server_ip:8080Log in with your password if prompted.
To access the server via SSH:
ssh your_username@your_server_ipYou can now access and manage `code-server` from a remote location.
Following these steps will have `code-server` installed and running on your server as a service, accessible from any device with a web browser. Refer to Github Repo for more details.