将服务器上的jupyter设置外网访问

自用记录~

1. 生成 notebook 配置文件

 jupyter notebook --generate-config

2.设置远程jupyter密码

在服务器进入jupyter

ipython
In [1]: from notebook.auth import passwd
In [2]: passwd()

 保存out[2]生成的密钥

3.修改配置文件

打开配置文件:

$ vim ~/.jupyter/jupyter_notebook_config.py

在jupyter/jupyter_notebook_config.py文件中加入登录的配置信息:

c.NotebookApp.ip = '0.0.0.0' #所有绑定服务器的IP都能访问,若想只在特定ip访问,输入ip地址即可
c.NotebookApp.password = u'argon2...' #刚才复制的那个密钥
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888    #指定一个端口记住
c.NotebookApp.allow_remote_access = True
c.NotebookApp.notebook_dir = u'/home' 

4.服务器中启动jupyter

启动:

jupyter notebook

#jupyter后台启动的方法
nohup jupyter notebook --allow-root  >> logs.out 2>&1 &

5.远程访问jupyter

打开浏览器输入http://ip:8888/,IP就是我们服务器的ip

密码就是刚刚我们在2中设置的密码

参考:参考博客

猜你喜欢

转载自blog.csdn.net/wan_ide/article/details/127534282