接受的答案/信息适用于旧版本。如何启用对新的 jupyter notebook 的远程访问?我得到了你的保障
首先,如果您还没有配置文件,请生成一个配置文件:
jupyter notebook --generate-config
请注意此命令的输出,因为它会告诉您jupyter_notebook_config.py
文件的生成位置。或者,如果您已经拥有它,它会询问您是否要使用默认配置覆盖它。编辑以下行:
## The IP address the notebook server will listen on.
c.NotebookApp.ip = '0.0.0.0' # Any ip
为了增加安全性,请输入 python/IPython shell:
from notebook.auth import passwd; passwd()
您将被要求输入并确认密码字符串。复制字符串的内容,其格式应为 type:salt:hashed-password。查找并编辑以下行:
## 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 = 'type:salt:the-hashed-password-you-have-generated'
## Forces users to use a password for the Notebook server. This is useful in a
# multi user environment, for instance when everybody in the LAN can access each
# other's machine through ssh.
#
# In such a case, server the notebook server on localhost is not secure since
# any user can connect to the notebook server via ssh.
c.NotebookApp.password_required = True
## Set the Access-Control-Allow-Origin header
#
# Use '*' to allow any origin to access your server.
#
# Takes precedence over allow_origin_pat.
c.NotebookApp.allow_origin = '*'
(重新)启动你的 jupyter notebook,瞧!