User Tools

Site Tools


en:programmation-jupyter

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
en:programmation-jupyter [2020/12/15 16:09]
admin
en:programmation-jupyter [2022/03/11 19:23] (current)
admin
Line 1: Line 1:
-===== Jupyter notebook =====+====== Jupyter lab ======
  
-You should secure your jupyter netbook. You can follow this procedure.+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.
  
-Create jupyter configuration file+====== Initial configuration ======
  
-  jupyter notebook --generate-config+You only need to do this setup once, not everytime you want to use the lab.
  
-Create jupyter password +First, we create a password. This way, it won't be a random key to login. 
- +  jupyter lab password 
-  jupyter notebook password +   
- +Second, we create an SSL key. This key will allow the server to run as an https server. Keep in mind this is 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
-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. +
-<code> +
-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 +
-</code> +
- +
-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.+
  
 +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.1608048581.txt.gz · Last modified: 2020/12/15 16:09 by admin