! Avi Alkalay ¡: Jupyter Notebook on Fedora with official packages and SSL

Share Button

Jupyter Notebooks are the elegant way that Data Scientists work and all software needed to run them are already pre-packaged on Fedora (and any other Linux distribution). It is encouraged to use your distribution’s packaging infrastructure to install Python packages. Avoid at any cost installing Python packages with pip, conda, anaconda and from source code. The reasons for this good practice are security, ease of use, to keep the system clean and to make installation procedures easily reproducible in DevOps scenarios.

Jupyter Notebook on Fedora with MathJax and Python
Jupyter Notebook on Fedora with MathJax and Python

This tutorial will teach you to setup a complete and functional Jupyter Notebook on Fedora the correct way, enabled to be securely accessible from anywhere. Tested on Fedora 28 and should work also on Red Hat systems.

  1. As root user, install packages and dependencies:
    dnf install python3-notebook mathjax crypto-utils

    In addition to the Python kernel, there is also a C kernel/runner/interpreter that you can install:

    dnf install python3-jupyter-c-kernel
  2. From now on as regular user, set a password to log into Notebook web interface and avoid those long tokens. Run the following command anywhere on your terminal:
    jupyter notebook password

    Type a password for yourself. This will create the file $HOME/.jupyter/jupyter_notebook_config.json with your encrypted password.

  3. Prepare for SSL generating self-signed certificate for Jupyter’s internal HTTPS server:
    cd $HOME/.jupyter
    keyutil -c genreq -g 2048 -s CN=jupyter -v 24 -a -o localhost.csr -k localhost.key -z /lib*/libc*so
    keyutil -c makecert -g 2048 -s CN=jupyter -v 120 -a -o localhost.crt -k localhost.key -z /lib*/libc*so

    We’ll use entropy from a system file (/lib/libc.so).

  4. Finish configuring Jupyter editing your $HOME/.jupyter/jupyter_notebook_config.json to look like this:
      "NotebookApp": {
        "password": "sha1:abf58...87b",
        "ip": "*",
        "allow_origin": "*",
        "open_browser": false,
        "websocket_compression_options": {},
        "certfile": "/home/aviram/.jupyter/localhost.crt",
        "keyfile": "/home/aviram/.jupyter/localhost.key",
        "notebook_dir": "/home/aviram/Notebooks"

    The parts in red must be changed to match your folders. Parts in blue where already there after step 2. Parts in green are the crypto-related files generated on step 3.

  5. Create a folder for your notebook files, as configured in step 4’s notebook_dir above:
    mkdir $HOME/Notebooks

Now you are all set. Just run Jupyter Notebook like this:

jupyter notebook

And access it from any browser on the network using the HTTPS protocol and the password you set on step 2:


In addition to the IPython environment, you’ll also get a web-based Unix terminal provided by terminado. Some people might find this useful while others find this insecure. You can disable this feature in the config file.

The post Jupyter Notebook on Fedora with official packages and SSL appeared first on Avi Alkalay.

Powered by WPeMatico

Share Button