Generate Cookie Secret

Encrypt your lab's cookie for security purposes:

Obtain administrative rights by requesting root access:

sudo -i

Create a new directory for the cookie secret:

mkdir /srv/jupyterhub

Generate a random number and save it as the cookie secret:

openssl rand -hex 32 > /srv/jupyterhub/jupyterhub_cookie_secret

Edit JupyterHub's configuration file:

nano /etc/jupyterhub/jupyterhub_config.py

Copy the following and add it to the file:

c.JupyterHub.cookie_secret_file = '/srv/jupyterhub/jupyterhub_cookie_secret'

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

Ensure that only the system administrator can read and write the cookie secret:

chmod 600 /srv/jupyterhub/jupyterhub_cookie_secret

Restart to ensure recognition of the new extension:

systemctl restart jupyterhub.service

Last updated