为啥要这样
可以远程用浏览器看服务器的文件目录,以及各种jupyter的好处:直接改代码,调试,它内嵌的读图也是特别舒服。
服务器安装jupyter notebook
我是给服务器装了anaconda,然后就自带了jupyter notebook。
配置jupyter notebook
- 登陆服务器
ssh username@address_of_remote
- 生成配置文件
$ jupyter notebook --generate-config
该指令会自动创建这个:~/.jupyter/jupyter_notebook_config.py
- 生成密码
打开python,创建密码:
from notebook.auth import passwd
passwd()
Enter password:
Verify password:
'sha1:xxxxxxxxxxxxxxxxxxxxxxx'
把密码'sha1:xxxxxxxxxxxxxxxxxxxxxxx'复制下来
- 修改配置文件
$ vim ~/.jupyter/jupyter_notebook_config.py
加上下面这几行
c.NotebookApp.allow_remote_access = True
c.NotebookApp.ip = '*'
c.NotebookApp.password = u'sha1:xxxxxxxxxxxxxxxxxxxx' #你的密码
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888
- 启动jupyter
$ jupyter notebook
远程访问
-
方法一:
本地浏览器访问
http://address_of_remote:8888(此方法可能由于防火墙问题出现失败) -
方法二:
- 在本地终端中输入:
ssh username@address_of_remote -L127.0.0.1:1234:127.0.0.1:8888- 本地浏览器访问
http://localhost:1234
看看效果,虚浮了,相逢恨晚,造化弄人啊(注意服务器那边的jupyter不能关闭)
