Local access to jupyter notebook on Linux server

1. Generate a configuration file

jupyter notebook --generate-config
This generates the .jupyter/jupyter_notebook_config.py configuration file.

2. Open python and generate a key:

>>>from notebook.auth import passwd
 
>>>passwd()
 
#Enter a new login password (used for local access)
 
#Confirm again
 
#Generate key, copy and save it and modify it to the configuration file

{

The second method to set a password

2. Generate a password
Open ipython and create a ciphertext password (in the ipython environment):
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:ce23d945972f:34769685a7ccd3d08c84a18c63968a41f1140274'
 
copy the generated ciphertext 'sha:ce...'

}


3. Modify the configuration file

vim ~/.jupyter/jupyter_notebook_config.py
Modify the content in the configuration file, remove the comment and save it. The configuration file is commented out by default. If you can’t find the content, just enter it in the file header and save it.

c.NotebookApp.ip='0.0.0.0' # is to set all ip addresses to be accessible
 
c.NotebookApp.password = u'sha:ce... # Copy the ciphertext key from the previous step to replace the content after the equal sign, Note, there is u'
 
c.NotebookApp.open_browser = False # Prohibit automatically opening the browser
 
c.NotebookApp.port =8888 # Specify an available port, or other idle ports

4. Open port 8888 in the firewall

Take CentOS 7 64-bit as an example:

Click: Fireproof window, non-root user, after entering the password, pass the authentication

Select public - port - add - add port 8888 and tcp protocol

5. Set the mapping native port and NAT settings on the virtual machine

Click on the virtual machine: Edit -> Virtual Network Editor -> 

Click NAT Settings ->

Click Add -> Enter the port and IP of the virtual machine, the default TCP protocol -> Confirm

 

6. Start the jupyter notebook service

# jupyter notebook

7. Enter the access address on this machine

Input: http://Virtual machine IP in step 5: 8888/tree

-> Enter the jupyter notebook page, prompt you to enter the password -> fill in the password you set in the second step, click OK

Guess you like

Origin blog.csdn.net/z136435458/article/details/92853982