User Tools

Site Tools


en:programmation-jupyter

Jupyter notebook

You should secure your jupyter netbook. You can follow this procedure.

Create jupyter configuration file

jupyter notebook --generate-config

Create jupyter password

jupyter notebook password

Create a certificate that is valid for 365 days. Adjust the number of days for your needs.

cd ~/.jupyter
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mykey.key -out mycert.pem

You can start jupyter with this command:

jupyter notebook --certfile=~/.jupyter/mycert.pem --keyfile=~/.jupyter/mykey.key

If you prefer to use a browser on a different machine, for example a laptop, you can use this command instead:

jupyter notebook --certfile=~/.jupyter/mycert.pem --keyfile=~/.jupyter/mykey.key --no-browser --ip=*

This command won't automatically start a browser and will allow any computer to connect to the jupyter server. Look at the statup log to see which port to connect to.

If you want this configuration to be permanent, you can add those options to the jupyter_notebook_config.py file.

echo "c.NotebookApp.certfile = u'$HOME/.jupyter/mycert.pem'" >> jupyter_notebook_config.py
echo "c.NotebookApp.keyfile = u'$HOME/.jupyter/mykey.key'" >> jupyter_notebook_config.py
echo "c.NotebookApp.open_browser = False" >> jupyter_notebook_config.py
echo "c.NotebookApp.ip = '0.0.0.0'" >> jupyter_notebook_config.py

You can then start jupyter with a shorter command.

jupyter notebook

If you intend to use jupyter remotely from a laptop that's not on our network, you'll have to create an ssh tunnel to be able to reach the server.

en/programmation-jupyter.txt · Last modified: 2020/12/15 16:09 by admin