-
生成配置文件:
jupyter notebook --generate-config
-
设置Jupyter远程访问密码:
jupyter notebook password
-
手动生成一个hash密码,输入
ipython
,再依次输入如下语句:注:这两个密码都是输入同一个,不同的密码没试过
from notebook.auth import passwd passwd() # 这里会输出hash密码,保存下来有用 exit()
-
将hash密码添加到配置文件中,输入
vi ~/.jupyter/jupyter_notebook_config.py
,打开第一步生成的配置文件,写入如下内容:# c = get_config() # c.IPKernelApp.pylab = "inline" c.NotebookApp.ip = "*" c.NotebookAPp.open_browser = False c.NotebookApp.password = u'sha1:510eb39a87fb:62750c222931916f55d75b53a7847aa062ca5a57' # c.NotebookApp.certfile = u'/home/hhh/.jupyter/mycert.pem' c.NotebookApp.port=1924 c.NotebookApp.notebook_dir = "/home/hhh/ipythonFiles/" c.NotebookApp.allow_remote_access = True
-
创建文件夹:
mkdir ipythonFiles
-
使修改的配置生效,输入:
jupyter notebook
-
放行Linux防火墙的端口
端口号要和配置文件的端口号一致
sudo firewall-cmd --zone=public --add-port=1924/tcp --permanent sudo systemctl restart firewalld # 使防火墙生效
-
启动Jupyter服务器,并让这个服务器后台运行:
nohup jupyter notebook &
nohup jupyter lab &
-
到本地浏览器输入:remote_server_ip:port
remote_server_ip:远程服务器IP地址
port:远程服务器端口号
感谢参考资料:如何设置远程访问的Jupyter Notebook服务器-04(服务器篇)
‘sha1:510eb39a87fb:62750c222931916f55d75b53a7847aa062ca5a57’
跑的另一个jupyter服务:(修改端口号,最好也修改路径)
# c = get_config()
c.IPKernelApp.pylab = "inline"
c.NotebookApp.ip = "*"
c.NotebookAPp.open_browser = False
c.NotebookApp.password = u'sha1:c510322c37eb:41a0997fe87cf205e4592eeeed5c0c213a4b2ae8'
# c.NotebookApp.certfile = u'/home/hhh/.jupyter/mycert.pem'
c.NotebookApp.port=1919
c.NotebookApp.notebook_dir = "/home/hhh/ipythonFiles_mylearning/"
c.NotebookApp.allow_remote_access = True
修改完后,需要激活配置文件:jupyter lab --config ~/.jupyter/jupyter_notebook_config_mylearning.py
使用不同的配置文件即可运行多个jupyter服务
放行 1919 端口
使用不同的配置文件,挂到服务器后台运行:
nohup jupyter notebook --config ~/.jupyter/jupyter_notebook_config_mylearning.py &