Remote Visual Studio Code in your browser
I just found a neat open source project https://coder.com/ that allows you to run the Visual Studio Code IDE on a remote machine and access it through a browser in the same way we use Jupyter.
The github repo for the project is here: https://github.com/cdr/code-server
Set up:
To get it up and running, find the latest release here: https://github.com/codercom/code-server/releases/latest
You can download and run the latest release from the terminal on your remote machine using the following terminal commands:
wget https://github.com/codercom/code-server/releases/download/{version}/code-server-{version}-linux-x64.tar.gz
tar -xvzf code-server-{version}-linux-x64.tar.gz
replace {version}
in the above with the appropriate version number e.g. 1.939-vsc1.33.1
is the latest version as I’m writing this.
change directory to the path where you just unzipped to:
cd code-server-{version}-linux-x64
Now you can launch the VS Code server using the command
sudo ./code-server -p {port} &
replacing {port}
in the above with the port of your choice - make sure that this is different from the port your Jupyter server is running on (I used 9090).
Remember that you’ll have the above forward this port appropriately in your ssh
command. So for example using GCP:
gcloud compute ssh --zone=$ZONE jupyter@$INSTANCE_NAME -- -L 8080:localhost:8080 -L {port}:localhost:{port}
again replacing {port}
with the port you chose to run your VS Code server on.
Now you’ll see some output on the command line including a one time password to log into your IDE:
Copy this password, navigate your browser to http://localhost:{port}
. You’ll be presented with a prompt to login:
Enter your password and you should get a familiar looking IDE inside your browser
Bonus - sshcode
https://coder.com/ has also built an awesome command line application that allows you to run VS Code automatically via ssh on a remote server.
https://github.com/cdr/sshcode
They support OSX, Linux, and the Windows (via WSL)
I need to spend some time seeing if I can get this working with GCP - I see that there’s an issue here with some advice on how to do this: https://github.com/cdr/sshcode/issues/2