Installing Jupyter notebooks on a Centos 7 server

Sun 15 January 2017

This is how I installed a jupyter notebook on a centos 7 server.

The server

The place that I work recently has just launched a pilot Infrastructure As A Service, uh-iaas, which is based on openstack.

To try this out I wanted to setup an instance of Jupyter notebook.

I will not document the server setup, but I used a plain Centos 7 images from the provided GOLDEN images in the iaas. This will work on pretty much any standard Centos 7 installation.

The packages

This is the packages we are going to need. epel-release is needed for certbot, and bzip2 is needed by the anaconda installer we are going to download later.

# yum update
# yum install epel-release
# yum install bzip2
# yum install certbot

Read more about EPEL here:

Jupyter stuff

We need a non-root user, this is good practice.

# useradd jupyter

For this guide we also grant the user jupyter full sudo without password. You should consider if you want to do this or not.

# echo 'jupyter ALL = (ALL) NOPASSWD: ALL' > /etc/sudoers.d/20-jupyter

Letsencrypt and certbot

We are going to enable passwordbased authentication on our Jupyter notebook installation. To protect the password from preying eyes we need to encrypt our traffic.

SSL certificates are provided to you for free, and with automatic renewal, by the great letsencrypt project.

# certbot certonly --standalone -d -d
# certbot renew --dry-run

You now have a valid certificate, and you have tested that it is renewable. Lets add it to our crontab.

# crontab -e

Put the following line into the crontab config and save it.

* 5,11 * * * certbot renew --quiet

Read more about certbot here:

Read more about letsencrypt here:

Read more about crontab here:

The Jupyter configuration

… now its time to switch to the jupyter user

# su jupyter

… this notebook folder will be the home for everything that you create in the notebook

$ mkdir ~/notebooks

… download the anaconda installer, install anaconda and generate a default config file

$ curl -o
$ bash
$ jupyter notebook --generate-config

Now we need to generate the login password for our Jupyter notebook installation.

$ python

… enter the following code in the python shell

import as ne
Enter password:
Verify password:
Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'

Exit the python shell and open the Jupyter notebook configuration file.

$ vi ~/.jupyter/

… find the following setting and insert your generated sha1 value like shown below. Remember to uncomment the c.NotebookApp.password setting too.

c.NotebookApp.password = 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'

And here is some more configuration that might be a good starter.

# Set options for certfile and keyfile
c.NotebookApp.certfile = u'/etc/letsencrypt/live/'
c.NotebookApp.keyfile = u'/etc/letsencrypt/live/'

# Set ip to '*' to bind on all interfaces (ips) for the public server
c.NotebookApp.ip = '*'

# It is a good idea to set a known, fixed port for server access
c.NotebookApp.port = 8888

# The password that provide access to the notebook
c.NotebookApp.password = sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed

# It gives no meaning opening a browser on localhost when running from a server like ours
c.NotebookApp.open_browser = False

# Set the directory what we want to serve notebooks from
c.NotebookApp.notebook_dir = 'notebooks'

Start your server and start playing with your new Jupyter notebooks.

$ sudo ~/anaconda3/bin/jupyter notebook --config ~/.jupyter/

Point your webbrowser and login with the password you created in the python shell.

Jupyter notebook installation