JupyterHub 5 on Ubuntu 24.04 on Azure User Guide
Overview
JupyterHub is the multi-user server for Jupyter notebooks: it signs people in, starts a notebook server for each of them and proxies their browser to it, so a team or a class works in JupyterLab from one machine without installing anything locally. The cloudimg image installs JupyterHub 5.5.5 with JupyterLab 4.6.6 and Notebook 7.6.5 in a Python 3.12 virtual environment at /opt/jupyterhub, on a hardened Ubuntu 24.04 LTS base patched at build time, with nginx serving the hub on port 80.
Sign-in uses the VM's own Linux accounts (PAM), and each user's notebook server and kernels run as that Linux user, in that user's home directory, never as root, so one user's files and processes are separate from another's. The image ships with no usable password: a one shot first boot service sets a unique password for the jupyter account on every VM and records it in a root only file. cloudimg's support team is on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours.
What is included:
- JupyterHub 5.5.5, JupyterLab 4.6.6 and Notebook 7.6.5 (BSD-3-Clause) in
/opt/jupyterhub, with configurable-http-proxy 5.1.1 on Node.js 18 - nginx on port
80, proxying to the hub on loopback with the websocket upgrade that notebook kernels need - Sign-in with Linux accounts through PAM (
PAMAuthenticator); only the users you allow may sign in - One notebook server per user, run as that Linux user (
LocalProcessSpawner), listening on loopback only - The
jupyteraccount as the hub administrator, with a unique password made on each VM's first boot jupyterhub.service,nginx.serviceandjupyterhub-5-firstboot.serviceas enabled systemd units- cloudimg's support team on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours
Prerequisites
An active Azure subscription, an SSH key pair, and a VNet plus subnet in the target region. Standard_B2s (2 vCPU / 4 GiB RAM) is a sensible starting point for a few users; size up for more users or heavier notebooks, since every user's kernels run on this VM. NSG inbound: allow 22/tcp from your management network and 80/tcp for the hub. Restrict 80/tcp to trusted networks and place TLS in front of it for production, since notebooks can run code on the VM.
Step 1 - Deploy from the Azure Marketplace
Sign in to the Azure Portal, choose Create a resource, search the Marketplace for JupyterHub 5 on Ubuntu 24.04 by cloudimg, and select Create. On Basics pick your subscription, resource group, region and size; under Administrator account choose SSH public key and paste your key; under Inbound port rules allow SSH (22) and HTTP (80). Review the defaults, then Review + create then Create.
Step 2 - Deploy from the Azure CLI
# Accept the Marketplace terms once per subscription (required before the first CLI deploy)
az vm image terms accept --urn cloudimg1647283583153:jupyterhub-5-ubuntu-24-04:default:latest
az vm create \
--resource-group <your-rg> \
--name jupyterhub \
--image cloudimg1647283583153:jupyterhub-5-ubuntu-24-04:default:latest \
--size Standard_B2s \
--admin-username azureuser \
--generate-ssh-keys \
--public-ip-sku Standard
Then open the web port:
az vm open-port --resource-group <your-rg> --name jupyterhub --port 80 --priority 900
Step 3 - Confirm the services are running
SSH in as the admin user you chose at deploy (azureuser in the CLI example above) and confirm the hub, nginx and the first boot service are active. nginx listens on port 80; the hub's proxy (127.0.0.1:8000) and the hub's API (127.0.0.1:8081) listen on loopback only.
systemctl is-active jupyterhub nginx jupyterhub-5-firstboot
/opt/jupyterhub/bin/jupyterhub --version
sudo ss -tlnp | grep -E ':(80|8000|8081) ' | awk '{print $4, $6}'

Step 4 - Retrieve your per-VM password
The image ships with no usable password. On the first boot of every VM, jupyterhub-5-firstboot.service sets a unique password for the jupyter account and records it, with the hub's address, in a root only credentials file. Read it with sudo:
sudo cat /etc/cloudimg-credentials.txt
The file holds JUPYTERHUB_URL (the VM's public address when Azure reports one at first boot; otherwise use your VM's public IP from the portal), JUPYTERHUB_USER (jupyter) and JUPYTERHUB_PASSWORD. The same password signs in to the hub and is the jupyter Linux account's password; change it at any time with sudo passwd jupyter.
sudo stat -c '%a %U:%G %n' /etc/cloudimg-credentials.txt

Step 5 - Sign in to the hub
Browse to http://<your-vm-public-ip>/. The hub shows its sign-in page; sign in as jupyter with the password from the credentials file. Any other name, a Linux account that is not allowed, or a wrong password is refused.

The hub starts your own notebook server and opens JupyterLab on its launcher, in the jupyter user's home directory.

Step 6 - Run a notebook
Choose Python 3 (ipykernel) under Notebook, type some Python in the first cell and press Shift+Enter. The kernel runs as your own Linux user, which you can see from inside the notebook:
import getpass, sys, jupyterlab
print("Hello from JupyterHub on Azure")
print("kernel user:", getpass.getuser())
print("Python", sys.version.split()[0], "| JupyterLab", jupyterlab.__version__)

Notebooks are saved in the user's home directory (/home/jupyter for the jupyter user), which only that user can read.
Step 7 - Check that each user's server runs as that user
From your SSH session, confirm the hub signs in with Linux accounts and starts each user's server as that user, and that the user's home is private to them. The process list shows each signed-in user's jupyterhub-singleuser server, plus an ipykernel_launcher line per running kernel, every one owned by that user and none by root:
grep -E '^c\.(JupyterHub\.(authenticator|spawner)_class|Authenticator\.(allowed|admin)_users)' /etc/jupyterhub/jupyterhub_config.py
ps -eo user:10,args | grep -E '[j]upyterhub-singleuser|[i]pykernel_launcher' | cut -c1-110
stat -c '%a %U:%G %n' /home/jupyter

Step 8 - Manage users from the admin page
As the administrator, open File > Hub Control Panel in JupyterLab (or browse to http://<your-vm-public-ip>/hub/admin) and choose Admin. The admin page lists every user, whether they are an administrator, when they were last active, and lets you start, stop or open their servers.

The hub's REST API answers on the same address; its root reports the running version:
curl -s http://127.0.0.1/hub/api/
Step 9 - Add your own users
Each hub user is a Linux account on the VM. To add one, create the account and give it a password:
sudo useradd -m -s /bin/bash <new-user>
sudo passwd <new-user>
Then add the name to allowed_users in /etc/jupyterhub/jupyterhub_config.py (add it to admin_users too if they should manage the hub), for example c.Authenticator.allowed_users = {'jupyter', '<new-user>'}, and restart the hub:
sudo systemctl restart jupyterhub
Restarting the hub stops the notebook servers that are running; users start theirs again when they next sign in, and their saved notebooks stay in their home directories. The new user signs in at the same address and gets their own server, running as their own Linux account, in their own home directory.
Security notes
- The hub serves on port 80 over plain HTTP. Restrict
80/tcpin the NSG to trusted networks and put TLS in front of it (for example a certificate on the bundled nginx, or Azure Application Gateway) before you use it over the internet. - The image ships with no usable password. The
jupyteraccount's password is set on each VM's first boot and kept in the root only file/etc/cloudimg-credentials.txt; change it withsudo passwd jupyter. - Only the users in
allowed_usersmay sign in, and onlyadmin_usersmay manage the hub. Anyone who can sign in can run code on the VM as their own Linux user, so give accounts only to people you trust with that. - Notebook servers listen on
127.0.0.1only and are reached through the hub's proxy; the hub's API is on loopback too. - Keep the VM patched. The image is patched at build time and ships with unattended security upgrades enabled. Python packages in
/opt/jupyterhubare updated withsudo /opt/jupyterhub/bin/pip install --upgrade <package>.
Support
cloudimg's support team is on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours. If you have any questions about this JupyterHub image or need help with your deployment, contact us through the cloudimg website.