JupyterHub Installation and Configuration

Obtain administrative rights by requesting root access:

$ sudo -i

Install the package for JupyterHub

$ conda install -c conda-forge jupyterhub

Generate a JupyterHub configuration file in /etc by:

$ mkdir /etc/jupyterhub/
$ cd /etc/jupyterhub/
$ jupyterhub --generate-config

Use nano to edit the newly created configuration file:

$ nano /etc/jupyterhub/jupyterhub_config.py

Copy and paste the following into the configuration file:

# Allow Jupyter Lab as the default interface
c.Spawner.default_url = '/lab'
# Allow admin to access other users' accounts
c.JupyterHub.admin_access = True
# Specify JupyterHub administrators
c.Authenticator.admin_users = {'admin1'}
# Shutdown user servers on logout
c.JupyterHub.shutdown_on_logout = True
# Prevent the user-owned configuration files from being loaded
c.Spawner.disable_user_config = True

Use CTRL+O then enter to overwrite the document and CTRL+X to exit.

💡 For having access to the JupyterHub admin interface, at least one administrator has to be specified in the configuration file, e.g. admin1. Additional administrators can be assigned/removed from the JupyterHub admin interface by existing administrator.

Make JupyterHub a system service, so that JupyterHub will run at system startup and continue to run after the system administrator logs out. To do so, create a service file:

$ nano /etc/jupyterhub/jupyterhub.service

Copy and paste the following into the document as depicted below:

After=syslog.target network.target
ExecStart=/usr/anaconda3/bin/jupyterhub --no-ssl -f /etc/jupyterhub/jupyterhub_config.py

Use CTRL+O then enter to overwrite the document and CTRL+X to exit.

Link the newly created service file to the /etc/systemd/system directory:

$ ln -s /etc/jupyterhub/jupyterhub.service /etc/systemd/system/jupyterhub.service

Reload the system daemon and run JupyterHub as a system service:

$ systemctl daemon-reload
$ systemctl enable jupyterhub.service
$ systemctl start jupyterhub.service

Check JupyterHub status (optional):

$ systemctl status jupyterhub.service

💡 Your JupyterHub server should be up and running at http://<your instance IP address>:8000. Make sure that :8000 is included in your address. See Add a Custom Domain to attach your JupyterHub to a registered domain name instead.

You are running an unsecured instance of JupyterHub. For network security, see below.