Jupyter Lab is only at version 0.32 at the time of writing, but it is already very promising. It is like a small IDE running in your web browser. It allows to conveniently edit and run files on a remote server. We tested Jupyter Lab on a connection with high latency (>300ms) and using the text editor, notebooks or the file manager was easy and reactive. Only the terminal was suffering from some lag, but at a level that was still bearable.
We are going to see now how to remotely connect to a server running Jupyter Lab.
In the following, we assume that you are already able to connect via ssh to your server.
Step-by-step instructions: the long way
1. Connect to your server
On local computer:
ssh $USER@$SERVER -p $SSHPORT
2. Activate your virtual environment
This step is only necessary if Jupyter is installed inside a virtual environment. Anaconda makes installing Jupyter Lab very easy and helps to keep a clean environment. We therefore use an Anaconda environment that is activated the following way on the remote server:
conda activate $CONDAENV
3. Start Jupyter Lab
On remote server:
jupyter lab --port=$JSPORT --no-browser &
An url is displayed to login with a token, we will use it at step 5.
4. Redirect the Jupyter server port to a local port
On local computer:
ssh -N -f -L $JLPORT:localhost:$JSPORT $USER@$SERVER -p $SSHPORT
5. Open in browser
Copy-paste the link provided at step 3 into your browser, and change the port to JLPORT.
A way shorter version
Use the same Jupyter port on both server and local machine. The JUPYTER variable represents the path to your jupyter binary. In case of using a miniconda environment, it is ~/miniconda3/envs/CONDAENV/bin/jupyter.
Type the following command to start jupyter lab and forward the ports at the same time:
ssh -L $JPORT:localhost:$JPORT $USER@$SERVER -p $SSHPORT $JUPYTER lab --no-browser --port $JPORT
Then just click on the displayed url to login with a token.