Running code-server on Ibex

code-server is an opensource alternative to running VS code on a remote machine.
The server instantiates on a remote host and the client can run in a browser. The following has been tested on Ibex’s GPUs node and client in Google Chrome on local workstation.

Please login to for the steps below. This is to isolate the processes invoked by VSCode.

It applies to those who are only interested to use Ibex’s filesystem in your local VS Code installation.

Step 1

Install code-server in your conda environment:

conda install -c conda-forge code-server

Step 2

You can run code-server remote server either interactively or in a batch job. Batch jobs are preferred


Allocate a node with e.g. GPU on Ibex (assuming you are on node):

srun --gpus=1 --time=01:00:00 --pty bash echo $(/bin/hostname)

Note the hostname of the node your job has been allocated. E.g. in this case I have been allocated dgpu501-22


Edit ~/.config/code-server/config.yaml to set a password of your choice and the port on host machine to bind to. For example, I do the following:

bind-addr: dgpu501-22:10121 auth: password password: 7days7nights cert: false

The above password will be needed to login to the client session.

Start code-server:

conda activate code-server code-server --auth=password --verbose

This will start the server within your GPU enabled interactive job. The output will look as follows:

[2022-04-18T12:47:40.598Z] trace child:103311 got message {"message":{"type":"handshake","args":{"bind-addr":"","auth":"password","password":"7days7nights","config":"/home/shaima0d/.config/code-server/config.yaml","verbose":true,"extensions-dir":"/home/shaima0d/miniconda3/envs/code-server/share/code-server/extensions","user-data-dir":"/home/shaima0d/.local/share/code-server","log":"trace","host":"","port":10121,"proxy-domain":[],"_":[],"usingEnvPassword":false,"usingEnvHashedPassword":false}}} [2022-04-18T12:47:40.602Z] info code-server 4.2.0 693b1fac04524bb0e0cfbb93afc85702263329bb [2022-04-18T12:47:40.602Z] info Using user-data-dir ~/.local/share/code-server [2022-04-18T12:47:40.602Z] trace Using extensions-dir ~/miniconda3/envs/code-server/share/code-server/extensions [2022-04-18T12:47:40.628Z] info Using config file ~/.config/code-server/config.yaml [2022-04-18T12:47:40.628Z] info HTTP server listening on [2022-04-18T12:47:40.628Z] info - Authentication is enabled [2022-04-18T12:47:40.628Z] info - Using password from ~/.config/code-server/config.yaml [2022-04-18T12:47:40.628Z] info - Not serving HTTPS

Batch job

Modify the following jobscript according to your parameters:

#!/bin/bash #SBATCH --time=00:10:00 #SBATCH --gpus=1 source $HOME/miniconda3/bin/activate ./codeserver export CODE_SERVER_CONFIG=~/.config/code-server/config.yaml export XDG_CONFIG_HOME=$HOME/tmpdir node=$(/bin/hostname) port=10121 user=$(whoami) submit_host=${SLURM_SUBMIT_HOST} if [ -f ${CODE_SERVER_CONFIG} ] ; then rm ${CODE_SERVER_CONFIG} fi echo "bind-addr: ${node}:${port}" >> $CODE_SERVER_CONFIG echo "auth: password" >> config echo "password: 10DowningStreet" >> $CODE_SERVER_CONFIG echo "cert: false" >> config echo "Copy the following line in a new terminal to create a secure SSH tunnel between your computer and Ibex compute node." echo "ssh -L localhost:${port}:${node}:${port} ${user}@${submit_host}" code-server --auth=password --verbose

Step 3

Port forwarding is required to bind to the listening port of the remote host (Ibex GPU node). For this, open a new terminal window and start an SSH tunnel to achieve the above:

ssh -L localhost:10121:dgpu501-22:10121

In the above command line, dgpu501-22 is the hostname of the machine our job is running (server is running). Use you username instead of shaima0d and the jump server/node is glogin login node.

In case you have submitted a batch job, please see the slurm output and copy the ssh command from there and paste it in a new terminal


Step 4

Once the SSH tunnel is established, you can open the URL that code-server is listening on in the browser to access VS code/code-server


Fill the password and your session is ready to use.


When finished, please exit the job on Ibex.