User Tools

Site Tools


en:programmation-jupyter

Jupyter lab

It's best to secure your jupyter lab with a password and an SSL certificate so the communication is crypted. The procedure also sets the port on which the server is running and preventing a web browser from starting.You can change the different options according to your needs.

Initial configuration

You only need to do this setup once, not everytime you want to use the lab.

First, we create a password. This way, it won't be a random key to login.

jupyter lab password

Second, we create an SSL key. This key will allow the server to run as an https server. Keep in mind this is a self-signed certificate and as such is not recognized by the browsers as being secure.

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

Third, we configure miscelaneous parameters of the lab

Certificate information

echo "c.ServerApp.certfile = u'$HOME/.jupyter/mycert.pem'" >> $HOME/.jupyter/jupyter_lab_config.py
echo "c.ServerApp.keyfile = u'$HOME/.jupyter/mykey.key'" >> $HOME/.jupyter/jupyter_lab_config.py

Don't start a browser

echo "c.ServerApp.open_browser = False" >> $HOME/.jupyter/jupyter_lab_config.py
echo "c.LabServerApp.open_browser = False" >> $HOME/.jupyter/jupyter_lab_config.py

Run on port 9000. Change this if needed

echo "c.ServerApp.port = 9000" >> $HOME/.jupyter/jupyter_lab_config.py

Once the setup is complete, you can start the program as usual:

jupyter lab

Remote access

If you wish to start a lab server on a machine and access it remotely, do as usual and create an ssh tunnel to the port you defined in your configuration. For example:

ssh mydesktopname -L9000:localhost:9000
en/programmation-jupyter.txt · Last modified: 2022/03/11 19:23 by admin