访问在AWS中运行的Jupyter-获取证书错误访问它

时间:2019-03-17 06:45:13

标签: amazon-ec2 jupyter-notebook

我按照本教程在AWS-ec2中安装Jupyter笔记本: https://medium.com/@alexjsanchez/python-3-notebooks-on-aws-ec2-in-15-mostly-easy-steps-2ec5e662c6c6

我被困在尝试从笔记本电脑访问笔记本电脑并出现以下错误的位置:

  

[E 06:33:24.239 NotebookApp]回调中的异常(,.null_wrapper位于0x7f5689fcdd90>)       追溯(最近一次通话):         文件“ /home/ubuntu/anaconda3/lib/python3.6/site-packages/tornado/ioloop.py”,   888行,开始时           handler_func(fd_obj,事件)         文件“ /home/ubuntu/anaconda3/lib/python3.6/site-packages/tornado/stack_context.py”,   第277行,在null_wrapper中           返回fn(* args,** kwargs)         文件“ /home/ubuntu/anaconda3/lib/python3.6/site-packages/tornado/netutil.py”,   276行,在accept_handler中           回调(连接,地址)         文件“ /home/ubuntu/anaconda3/lib/python3.6/site-packages/tornado/tcpserver.py”,   _handle_connection中的第264行           do_handshake_on_connect = False)         文件“ /home/ubuntu/anaconda3/lib/python3.6/site-packages/tornado/netutil.py”,   ssl_wrap_socket中的第517行           上下文= ssl_options_to_context(ssl_options)         文件“ /home/ubuntu/anaconda3/lib/python3.6/site-packages/tornado/netutil.py”,   ssl_options_to_context中的第494行           context.load_cert_chain(ssl_options ['certfile'],ssl_options.get('keyfile',None))

     

PermissionError:[Errno 13]权限被拒绝

我的jupyter笔记本配置在下面

> c = get_config()
> 
> # Kernel config c.IPKernelApp.pylab = 'inline'  # if you want plotting support always in your notebook
> 
> # Notebook config c.NotebookApp.certfile = u'/home/ubuntu/certs/mycert.pem' #location of your certificate file
> c.NotebookApp.ip = '*' c.NotebookApp.open_browser = False  #so that
> the ipython notebook does not opens up a browser by default
> c.NotebookApp.password = u'sha1:262....your hash here.........65f' 
> #edit this with the SHA hash that you generated after typing in Step 9
> # This is the port we opened in Step 3. c.NotebookApp.port = 8888

1 个答案:

答案 0 :(得分:0)

在上述问题中共享的Jupyter笔记本配置文件中,请按照以下步骤进行一些更改。

要彻底配置jupyter配置文件,请按照以下步骤操作:

cd ~/.jupyter/

vi jupyter_notebook_config.py

enter image description here

在文档的开始处插入它:

c = get_config()
# Kernel config
c.IPKernelApp.pylab = 'inline'  # if you want plotting support always in your notebook
# Notebook config
c.NotebookApp.certfile = u'/home/ubuntu/certs/mycert.pem' #location of your certificate file
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.open_browser = False  #so that the ipython notebook does not opens up a browser by default
c.NotebookApp.password = u'sha1:98ff0e580111:12798c72623a6eecd54b51c006b1050f0ac1a62d'  #the encrypted password we generated above
# Set the port to 8888, the port we set up in the AWS EC2 set-up
c.NotebookApp.port = 8888

一旦您输入了以上这些行,请确保保存配置文件,然后再退出vi编辑器! 而且,最重要的是,请记住用您的密码替换sha1:98ff0e580111:12798c72623a6eecd54b51c006b1050f0ac1a62d!

请注意,由于在上面的配置文件中,我们将端口指定为8888,因此在安全组中添加了相同的端口。 (自定义TCP类型,TCP协议,端口范围为8888,并且自定义源)

现在你很好!

键入以下命令:

screen

此命令将允许您在继续在ec2实例上执行其他工作的同时,为Jupyter进程日志创建单独的屏幕。

现在,通过键入以下命令来启动jupyter笔记本:

jupyter notebook

要从本地计算机的浏览器访问jupyter笔记本,请执行以下操作:

您的EC2实例将具有长网址,如下所示:

ec2-52-39-239-66.us-west-2.compute.amazonaws.com

在本地浏览器中访问该URL。如下所示,确保在开头有https,在结尾有8888端口。

https://ec2-52-39-239-66.us-west-2.compute.amazonaws.com:8888/

这应该使它运行。