jupyer virtual machine remote access configuration

Since jupyter is installed on the server, I want to access the jupyter kernel locally.

I don't know if it must be on the same network segment. Due to school access problems, it must be confirmed that it is on the same network segment.

Start configuration:

  1. Generate a configuration file
    (I use the root user for configuration here, but it is recommended to use a normal user)
[root@localhost Python-3.6.5]# jupyter notebook --generate-config
Writing default config to: /root/.jupyter/jupyter_notebook_config.py
  1. Generate a password file
    If you need to log in with a password when you want to access jupyter remotely, you can have this step. If you use it yourself, it's better to get one.
## Hashed password to use for web authentication.
#  
#  To generate, type in a python/IPython shell:
#  
#    from notebook.auth import passwd; passwd()
#  
#  The string should be of the form type:salt:hashed-password.
#c.NotebookApp.password = ''

You can see how to generate a password file is given in the file:

[root@localhost Python-3.6.5]# python3
Python 3.6.5 (default, Jan 10 2019, 04:19:43) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from notebook.auth import passwd;passwd()
Enter password: 
Verify password: 
'sha1:ac5012e9f4***********706f19ee9938bef6'

Be sure to copy this string of sha1 codes.

  1. Modify the configuration file to achieve remote access
    Open the configuration file we generated in the first step, the
    ## The IP address the notebook server will listen on. c.NotebookApp.ip = '0.0.0.0'
    line 204 will be localhostchanged *, meaning to allow any ip access.
    c.NotebookApp.open_browser = False
    Line 267 changes True to False. and remove the preceding sentence #. Prevents the browser from being actively opened.
    c.NotebookApp.password = 'sha1:ac5012e9f4ce:bdfdd4b96f6d5cf59aa484a1706f19ee9938bef6‘
    Line 276 is removed #, and the sha code generated in the previous step is copied here.
    c.NotebookApp.port = 8855
    In line 287, #remove the port before the port. The port can be modified or not, as long as you like it.

save, exit.

I have a lot of troublesome problems during the installation, let's solve them one by one
System, centos7, python3.6.5, the latest jupyter.

socket.gaierror: [Errno -2] Name or service not known
OSError: [Errno 99] Cannot assign requested address

First confirm whether your firewall is closed
centos7 command is as follows:

firewall-cmd --state#查看防火墙状态
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动

Some netizens said that adding in /etc/hostname

127.0.0.1 localhost

I didn't notice any difference.
Then the root user I use needs to add --allow-rootparameters.

jupyter notebook --allow-root

Then enter the ip: port number of the server on the local computer to access it.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326303712&siteId=291194637