Introduction
This is a quick walk-through for how to run jupyter-lab in the CSIF.
Figure out your Port and CSIF system
In order to avoid collisions with other students using jupyter-lab on a system in the CSIF, you should use a different port number for your port in the examples below. Your instructor may assign you a range to use, for example 20001-20010. Use one of those ports, and if it’s not open, try another.
You will be able to tell if a port was occupied by this message when jupyter-lab starts (note the time will probably be different):
[I 17:15:18.616 LabApp] The port 20000 is already in use, trying another port.
Logging in with an SSH Tunnel
You will be using an SSH tunnel to encrypt your data from the CSIF to your remote location using an SSH tunnel.
In these examples, you will start jupyter-labs with a port number; use that port number in place of local_port and destination_port.
Mac/Linux
On macOS or any Linux desktop or laptop, open a terminal and use SSH to tunnel to a CSIF system:
$ ssh -L local_port:localhost:destination_port yourlogin@pc##.cs.ucdavis.edu
This command opens the port you set at destination_port from pc##.cs.ucdavis.edu to a local_port on your desktop or laptop (called localhost). Use the same port number for both, to keep it simple.
In this case, connecting jupyter-lab to the port you set on destination_port will make it available on your system (localhost) on the local_port.
For example
If you decide to use port 20001, and also pc41.cs.ucdavis.edu, then use this command to connect to pc41:
Windows
Command Prompt with OpenSSH
First, you should Activate Windows 10 OpenSSH Client for Use in the CSIF and then use OpenSSH by using this command in a Command Prompt:
For example
If you decide to use port 20001, and also pc41.cs.ucdavis.edu, then use this command to connect to pc41:
Ubuntu on Windows
You can install and use Ubuntu on Windows, then OpenSSH by launching Ubuntu by typing "ubuntu" on the command-line prompt (cmd.exe), or click on the Ubuntu tile in the Start Menu. Once the command line terminal is open, type this command and hit enter:
For example
If you decide to use port 20001, and also pc41.cs.ucdavis.edu, then use this command to connect to pc41:
PuTTY
It is not advised to use PuTTY as there were some difficulties with implementation. In theory it should work, but the two solutions above do work and are the recommended solutions.
Starting Jupyter-lab
To start jupyter-lab, use the port number you chose, and in your SSH terminal window, type:
For example
If the port you are using is 20001, this is what you should type in your terminal:
It will display something like:
[I 17:49:57.790 LabApp] JupyterLab extension loaded from /usr/local/lib/python3.6/dist-packages/jupyterlab
[I 17:49:57.790 LabApp] JupyterLab application directory is /usr/local/share/jupyter/lab
[W 17:49:57.792 LabApp] JupyterLab server extension not enabled, manually loading...
[I 17:49:58.240 LabApp] JupyterLab extension loaded from /usr/local/lib/python3.6/dist-packages/jupyterlab
[I 17:49:58.241 LabApp] JupyterLab application directory is /usr/local/share/jupyter/lab
[I 17:49:58.242 LabApp] Serving notebooks from local directory: /home/gribble
[I 17:49:58.242 LabApp] The Jupyter Notebook is running at:
[I 17:49:58.242 LabApp] http://localhost:20001/?token=a775c922afd5e0688a08b4ffb1659ef74dfa04e608b221c2
[I 17:49:58.242 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 17:49:58.242 LabApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:20001/?token=a7xxxxxfd5e0688a08b4ffb1659ef7xxxx04xxx8b221c2
That last part (in bold) is the URL you will use in your browser on your desktop or laptop, although your token will be different from this example.
Browsing your Jupyter notebooks
Open your browser on your desktop or laptop and paste in the URL you were given as in the example above. Note that the token will change each time, so you shouldn’t bookmark this link.
You should now have Jupyter in your browser, running on the CSIF system you logged into.
Troubleshooting
Browser says: “This site can’t be reached”
In general, if you cannot make a browser connection, make sure you are using the correct port, and make sure that port isn’t already in use, by checking the output of jupyter-lab when starting. See Port is already in use, below.
Port is already in use
[I 17:15:18.616 LabApp] The port 20000 is already in use, trying another port.
The port you chose is already in use. Please try a new port. You will need to logout and login again with SSH.
Blue screen appears, is very difficult to read, and makes me answer yes/no questions… UGH!
Make sure to use the two options when starting jupyter-labs : -y --no-browser (see above).
Optionally you can hit y three times, then hit Q to Quit. This will then show you the screen you’d see if you used the -y --no-browser options.
Further Reading
Jupyter-lab documentation
https://jupyterlab.readthedocs.io/en/stable/index.html
SSH Tunnels
https://www.ssh.com/ssh/tunneling/#what-is-an-ssh-tunnel?