http://blog.csdn.net/du_qi/article/details/51427857
https://www.cnblogs.com/yangxiaolan/p/5778305.html
实现标题所描述的功能,需要在Liunx服务器端和windows客户端分别进行配置,需要配置的内容如下:
1、Linux服务器端配置
(1)启动ipython,$ ipython
(2)创建远程连接密码,
In [1]: from notebook.auth importpasswd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:76f61bc8e014:3bcaf88be9148409460e9855e96a40aebbf9af41'
输入两次密码,将得到一个字符串,比如'sha1:76f61bc8e014:3bcaf88be9148409460e9855e96a40aebbf9af41',该终端不要关掉,复制该字符串,后面会用到;
(3)生成jupyter的配置文件,$ jupyter notebook --generate-config,将会在home目录下生成一个隐藏文件夹.jupyter,该文件夹中有一个jupyter的配置文件;
(4)打开配置文件,$ vim ~/.jupyter/jupyter_notebook_config.py,复制以下内容粘贴到配置文件中
c.NotebookApp.ip = '*'
c.NotebookApp.password = u' sha1:d0270e88f33b:212384922803ca9bd49d1fb6c11ab42651ccb358'#这里需要改为第(2)步你自己电脑上生成的密钥字符串
c.NotebookApp.open_browser=False c.NotebookApp.port = 9001 //随便制定一个
c.InteractiveShellApp.matplotlib = 'inline'
(5)设置jupyter notebook在后台不间断运行,且配置成错误信息输出到屏幕(可选),$ nohup jupyter notebook >/dev/null 2>&1 &
2、windows客户端配置
(1)需要安装一个windows远程ssh登录Linux的工具,可以是Xshell或SecureCRT,这两个工具的安装简单,如果遇到问题请自行百度;
(2)Xshell或SecureCRT第一次启动需要新建连接,一般输入服务器IP地址、用户名、密码即可,这里不细述;
(3)如果安装了Xshell,在Xshell的菜单栏,点击文件-属性-SSH-隧道-添加,侦听端口输入9001,目标主机设为服务器的IP地址,目标端口设为9001,“说明”中填入jupyter,确定。如果安装了SecureCRT,点击Options-Session Options-Port Forwarding-Add,name中填入jupyter,第一个port填入9001,勾选“Destination host is different from the SSH server”,填入服务器的IP地址,port填入9001,点两次OK;
(4)在第(2)步成功远程登录命令行窗口中输入 $ jupyter notebook;
(5)打开本地windows的浏览器,地址栏输入localhost:9001,回车,输入Linux服务器端配置时第(2)步设置的密码,回车,jupyter界面就出来了。
错误解决:
如果浏览器连接错误,可能是port设置错了,注意查看运行了 $ jupyter notebook的窗口中的内容,如果最下面几行是这样的:
[I 22:24:20.259 NotebookApp] The port 9001 is already in use, trying another port.
[I 22:24:20.264 NotebookApp] Serving notebooks from local directory: /home/duqi/genderPredict_duqi
[I 22:24:20.264 NotebookApp] 0 active kernels
[I 22:24:20.264 NotebookApp] The Jupyter Notebook is running at: http://[all ip addresses on your system]:9002/
[I 22:24:20.264 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 22:24:20.265 NotebookApp] No web browser found: could not locate runnable browser.
注意到第一行说明9001端口被使用了,第四行提示Jupyter Notebook在9002端口运行,这样的话就需要更改第(3)步中的本机端口设置为9002,然后在浏览器中也是输入9002