Ubuntu 16.04 LTS 配置 Jupyter notebook 为服务器

原材料:

Ubuntu 16.04 LTS 64bit

已经配置好 IPython 和 Jupyter (安装步骤可以参照:http://www.cnblogs.com/McKean/p/6194977.html)

一、使用OpenSSL产生 *.key 和 *.pem 密钥

cd ~/.jupyter 切换到.jupyter目录

openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mykey.key -out mycert.pem

成功的话,会在.jupyter目录下面产生 mykey.key 和 mycert.pem 两个文件

注意:这个OpenSSL是可选的,即使不适用OpenSSL也可以配置 jupyter使得局域网里面可以访问的。

二、设置密钥的sha1码

可以在IPython里面输入一下命令并按照提示输入密码,即可产生你需要密码对应的sha1值。

In [1]: from notebook.auth import passwd

In [2]: passwd()
c:\python27\lib\getpass.py:92: GetPassWarning: Can not control echo on the termi
nal.
  return fallback_getpass(prompt, stream)
Warning: Password input may be echoed.
Enter password: 12345678
Warning: Password input may be echoed.
Verify password: 12345678
Out[2]: 'sha1:c88810a822cf:2a10d54101bf6b326351c15f0c7b9fede372ef23'

  

三、产生并配置 jupyter_notebook_config.py 文件

使用 ls 命令查看.jupyter 目录下面有没有 jupyter_notebook_config.py 文件

如果没有,则使用 jupyter notebook --generate-config 命令产生一个

默认jupyter_notebook_config.py的配置都使用#注释掉,下面需要开启所需要的命令。

这里password 一项要使用前面产生的sha1值## The full path to an SSL/TLS certificate file.c.NotebookApp.certfile = u'/home/peter/.jupyter/mycert.pem

## The IP address the notebook server will listen on.
c.NotebookApp.ip = '192.168.242.139'
 
#  The string should be of the form type:salt:hashed-password.
c.NotebookApp.password = u'sha1:96d749b4e109:17c2968d3bc899fcd41b87eb0853a42ceb48c521'
 
## The port the notebook server will listen on.
c.NotebookApp.port = 8888

c.NotebookApp.open_browser = False

  

配置Jupyter notebook的默认目录

c.NotebookApp.notebook_dir = u'/home/peter/Git/MatlabMisc/Jupyter'

  

四、启动Jupyter notebook

在~/.jupyter目录下,输入下面命令即可
sudo jupyter notebook --certfile=mycert.pem --keyfile mykey.key

然后在其他机器上,输入 https://192.168.242.139:8888 (这里的ip是根据你自己的环境和在jupyter_notebook_config.py 文件配置的ip)

再输入密码即可

 

转载于:https://www.cnblogs.com/McKean/p/6391380.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值