(1)生成配置文件:
jupyter notebook --generate-config
(2)设置密码,记住密钥:
from notebook.auth import passwd
passed()
(3)修改/.jupyter/jupyter_notebook_config.py:
c.NotebookApp.ip = '*' # 允许访问此服务器的 IP,星号表示任意 IP
c.NotebookApp.password = u'sha1:xxx:xxx' # 之前生成的密码 hash 字串, 粘贴进去
c.NotebookApp.open_browser = False # 运行时不打开本机浏览器
c.NotebookApp.port = 8890 # 使用的端口,随意设置
c.NotebookApp.enable_mathjax = True # 启用 MathJax
c.NotebookApp.allow_remote_access = True #允许远程访问
(4)终端中输入:
ssh -L 8890:localhost:8890 wxzhou@172.31.226.122 -p 22
(5)浏览器中输入:
localhost:8890