远程Jupyter notebook

远程架设 Jupyter notebook

在远程安装好 jupyter notebook 后,生成配置文件

# 安装
pip3 install Jupyter
jupyter notebook --generate-config
# output: Writing default config to: /root/.jupyter/jupyter_notebook_config.py

之后进入 Python,输入命令来生成加密后的密码

from notebook.auth import passwd
passwd()

这个命令会让你输入密码,这个密码在远程登录时会用到,输完密码后会生成一个字符串,需要记录下来

Enter password: 
Verify password: 
# output: argon2:$argon2id$v...

在 jupyter notebook 的配置文件:jupyter notebook --generate-config 生成的文件中修改。

c.NotebookApp.password = 'argon2:$argon2id$v...'  # 刚刚生成的密钥
c.NotebookApp.ip= '0.0.0.0'                       # 服务器 ip,也可以是 '*'
c.NotebookApp.open_browser = False                # 禁止浏览器打开,因为是远程登录
c.NotebookApp.port = 8888                         # 自定义端口

之后在远程运行 jupyter notebook;本地用浏览器登录 <远程服务器IP>:<自定义端口>,比如 8.123.12.66:8888,再输入密码即可。

posted @ 2022-11-01 23:58  Violeshnv  阅读(25)  评论(0编辑  收藏  举报