Visual Studio Code open source edition is a great way for developers to work with a slick integrated development environment (IDE). You can install this tool on your desktop or you could run it over your network, so anyone on your LAN could have access to it. This is a great way to ensure you can work with the tool, no matter what computer you’re using.
The downside is that it’s a single-user instance, so you won’t be using this as a collaboration tool (in the normal sense of the word). Multiple users can access Visual Studio Code in this fashion, but work is not shared. The benefit of using Code in this manner is that no matter what platform you’re using it on, you’ll always have the same experience–if you’re working on a Linux desktop, a macOS laptop, an Android tablet, or a smartphone, it’ll all be the same.
So how do you get this up and running? Let me show you.
SEE: Serverless computing: A guide for IT leaders (TechRepublic Premium)
What you’ll need
You can create a networked instance of Visual Studio Code on a Linux or macOS machine, or using a Docker image. I am going to demonstrate how to make this work using Ubuntu Server 18.04, so you’ll need an instance of Linux up and running as well as a user with sudo privileges.
I will mention that the documentation found on the code-server site seems to always fail to create a running instance of code-server. However, I have found a method that does work, it’s just not quite as simple.
How to download and unpack code-server
The first thing you’ll want to do is download and unpack the code-server file. To do that, open a terminal window and issue the command:
Unpack that file with the command:
tar xvzf code-server-3.4.1-linux-x86_64.tar.gz
This will create a new folder named, code-server-3.4.1-linux-x86_64. Change into that new folder with the command:
How to create the config file
Before we start the server, we have to create a config file. To do that, first create a new directory with the command:
mkdir -p ~/.config/code
Now create the config file with the command:
In that new file, paste the following:
Where IP_ADDRESS is the IP address of the hosting machine and PASSWORD is a strong/unique password.
Save and close the file.
How to start the server
Now we have to start the server. To do that, change into the bin directory with the command:
Now, issue the command:
You should see the address of your server printed out (Figure A).
How to access code server
Point a web browser to the address listed in the command printout. You will be prompted to enter the password you created in the config file (Figure B).
Once you successfully authenticate, you’ll be greeted by the Visual Studio Code application where you can begin working (Figure C).
How to create a systemd file
Of course, you don’t want to have to run the Code Server command every time you need to access the service. For that, we must create a systemd file. To do that, issue the command:
sudo nano /lib/systemd/system/code-server.service
In that file, place the following:
ExecStart=/home/USER/code-server1/code-server-3.4.1-linux-x86_64/bin/code-server --bind-addr IP_ADDRESS:8080 --user-data-$
Where password is the same password you created in the config file, USER is your Linux username, and IP_ADDRESS is the IP address of the hosting machine.
Save and close the file.
Reload the systemctl daemon with the command:
sudo systemctl daemon-reload
Now you can start and enable code-server with the commands:
sudo systemctl start code-server
sudo systemctl enable code-server
At this point, code-server will always be running, even if the system reboots.
And that’s how you can serve up an instance of Visual Studio Code over your network. It’s a bit of a franken-solution, but it works really well.
Subscribe to the Cloud Insider Newsletter
This is your go-to resource for the latest news and tips on the following topics and more, XaaS, AWS, Microsoft Azure, DevOps, virtualization, the hybrid cloud, and cloud security. Delivered Mondays and Wednesdays