用Xshell远程连接服务器上的jupyter notebook(附新版本更改密码)
今天浅写一下在Xshell远程连接服务器上已有的jupyter notebook,以后更新一下如何在服务器上部署jupyter notebook。
(1)生成config文件
打开服务器并登录,进入所需要的环境之后,输入:
jupyter notebook --generate-config
输入y,生成文件路径(后面有用)
(2)生成密码
打开python/ipython,创建密文的密码:
(base) root@c21***:~# python
from notebook.auth import passwd
passwd()
#输入两次密码
#Enter password:
#Verify password:
#然后出现
#'sha1:xxxxxxxxxxxxxxxxx'
(3)修改config文件
复制第一步生成的路径,进入该文件
vim ~/.jupyter/jupyter_notebook_config.py
然后进行如下修改:
c.ServerApp.ip='*'
c.ServerApp.password = u'sha:xxxxxx'#第二步生成的,复制过来
c.ServerApp.open_browser = False
c.ServerApp.port =7548 #随便指定一个
(4)新版本下的改变
由于jupyter更新版本了,如果你用的是最新版本,在第(2)步开始进行以下改变:
jupyter notebook password
输入两次密码
接着进入上面第(3)步
复制第一步生成的路径,进入该文件
vim ~/.jupyter/jupyter_notebook_config.py
然后进行如下修改:
c.ServerApp.ip='*'
c.ServerApp.open_browser = False
c.ServerApp.port =7548 #随便指定一个
结束进入第(5)步
(5)添加Xshell的channel
右键Xshell左侧的会话—属性—隧道:
点击添加
侦听端口随便填,目标端口填第三步中的7548(自己设什么填什么)
(5)运行jupyter notebook
输入jupyter notebook
在本地的浏览器输入127.0.0.1:7548,7548是上一步设置的侦听端口(用自己设的)。
输入密码之后,就可以正常使用了~
插播一个可能遇到的问题
在输入jupyter notebook的时候,出现:
Running as root is not recommended. Use --allow-root to bypass.
解决方法:
进入第一步生成的文件:
vim ~/.jupyter/jupyter_notebook_config.py
找到这一行:
#c.NotebookApp.allow_root = False
去掉#,并修改成True:
c.NotebookApp.allow_root =True
保存退出,重新运行jupyter notebook
有用的三连一下吧~
https://blog.youkuaiyun.com/dusy111/article/details/79301296
https://blog.youkuaiyun.com/weixin_39777626/article/details/80371659