VS Code Server
If you have a home server very powerful running locally, you want to use it as a code server. There are two ways to do it:
Download a VS code in the client and connect to the server using vscode remote extension through ssh.
However, not all the client devices are available to install the vscode, especially those mobile devices. So, the second way is to use vscode server.
In this article, We will setup the local vscode server in the home server so that my mobile device can access it through the browser.
Install VS code cli
As the home server is running Ubuntu server w/o GUI, we can install the vscode cli using snap.
sudo snap install code --classic
- Reference link: https://code.visualstudio.com/docs/setup/linux#_snap
After installing the vscode cli, we can use the code
command to open the vscode in the terminal.
Create VS code server
We can create the vscode server using the following command:
code tunnel
If it is the first time to run the command, it will ask you to login with your github account. After that, it will create a tunnel to the vscode server.
Example output
eric@home-server-acer:~$ code tunnel
*
* Visual Studio Code Server
*
* By using the software, you agree to
* the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-license) and
* the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacystatement).
*
[2024-08-19 08:45:16] info Using GitHub for authentication, run `code tunnel user login --provider <provider>` option to change this.
To grant access to the server, please log into https://github.com/login/device and use code BOBF-8XBF
Once the github auth is done, we can see below.
[2024-08-19 08:46:11] info Creating tunnel with the name: home-server
Open this link in your browser https://vscode.dev/tunnel/home-server
Now we can open the link in the browser to access the vscode server.
persist the tunnel
If we want to persist the tunnel, we can use the following command:
code tunnel > code_tunnel_out 2> code_tunnel_err & disown
> code_tunnel_out
will redirect the stdout to the filecode_tunnel_out
2> code_tunnel_err
will redirect the stderr to the filecode_tunnel_err
& disown
will run the command in the background. Thedisown
command is used after the&
to remove the process from the shell's job table.reference link: https://stackoverflow.com/questions/75805472/how-can-i-keep-code-tunnel-running-in-the-background