Skip to main content
Computer Science Instructional Facility (CSIF)
UC Davis Logo
UC Davis Logo

Computer Science Instructional Facility (CSIF)

Computer Science
  • UC Davis

Main navigation (extended config)

  • Home
  • Using the CSIF
    • Accessing the CSIF Computers (remotely)
    • Accounts and Passwords
      • Instructional Accounts in the CSIF
      • Who has Access to the CSIF
    • Computers Use
      • File Storage
      • How do I setup and use Handin and rcvhandin?
      • How to run jupyter-lab in the CSIF
      • Learning Bash
      • Requesting Software to be Installed in the CSIF
      • rclone for Backups
      • Setting Up SSH Keys For Single Sign-On
      • SSH
      • Using the Ubuntu Software Repository
  • FAQ
  • Support
  • Lost and Found
  • About

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

SSH is a standard for secure remote logins and file transfers over untrusted networks. It also provides a way to secure the data traffic of any given application using port forwarding, basically tunneling any TCP/IP port over SSH. This means that the application data traffic is directed to flow inside an encrypted SSH connection so that it cannot be eavesdropped or intercepted while it is in transit. SSH tunneling enables adding network security to legacy applications that do not natively support encryption. — What is an SSH tunnel? From SSH.com

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 computer networking, localhost is a hostname that refers to the current computer used to access it. — Wikipedia entry on localhost

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:

$ ssh -L 20001:localhost:20001 youraccount@pc41.cs.ucdavis.edu

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:

$ ssh -L local_port:localhost:destination_port yourlogin@pc##.cs.ucdavis.edu

For example

If you decide to use port 20001, and also pc41.cs.ucdavis.edu, then use this command to connect to pc41:

$ ssh -L 20001:localhost:20001 youraccount@pc41.cs.ucdavis.edu

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:

$ ssh -L local_port:localhost:destination_port yourlogin@pc##.cs.ucdavis.edu

For example

If you decide to use port 20001, and also pc41.cs.ucdavis.edu, then use this command to connect to pc41:

$ ssh -L 20001:localhost:20001 youraccount@pc41.cs.ucdavis.edu

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:

$ jupyter-lab -y --no-browser --port=your_port

For example

If the port you are using is 20001, this is what you should type in your terminal:

$ jupyter-lab -y --no-browser --port=20001

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?

 

 

UC Davis footer logo

University of California, Davis, One Shields Avenue, Davis, CA 95616 | 530-752-1011

  • Questions or comments?
  • Privacy & Accessibility
  • Principles of Community
  • University of California
  • Sitemap
  • Last update: October 27, 2023

Copyright © The Regents of the University of California, Davis campus. All rights reserved.

This site is officially grown in SiteFarm.