Mycert.pem 在 aws 上安装 ipython notebook 时不存在

Mycert.pem does not exist while instally ipython notebook on aws

我目前正在尝试在 aws 上安装 jupyter notebook。 但是有一个错误显示 "mycert.pem" 没有退出。

我 运行 在我的本地终端上输入以下行,并在本地文档中得到 mykey.key & mycert.pem

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

代码在我的 jupyter_notebook_config.py

c= get_config()
c.IPKernelApp.pylab = 'inline'  # if you want plotting support always in your notebook

c.NotebookApp.certfile = u'/Users/leigh/mycert.pem ' #location of your certificate file
c.NotebookApp.keyfile = u'/Users/leigh/mykey.key '
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888
c.NotebookApp.password = u'sha1:eaa28116dc5f:________'

当我在 aws 上 运行 "jupyter notebook" 它显示以下错误

  File "/home/ec2-user/anaconda2/bin/jupyter-notebook", line 6, in <module>
    sys.exit(main())
  File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/traitlets/config/application.py", line 591, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-114>", line 2, in initialize
  File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/traitlets/config/application.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
  File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/notebook/notebookapp.py", line 1007, in initialize
self.init_webapp()
  File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/notebook/notebookapp.py", line 868, in init_webapp
xheaders=self.trust_xheaders)
  File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/tornado/util.py", line 215, in __new__
instance.initialize(*args, **init_kwargs)
  File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/tornado/httpserver.py", line 155, in initialize
read_chunk_size=chunk_size)
  File "/home/ec2-user/anaconda2/lib/python2.7/site-packages/tornado/tcpserver.py", line 112, in __init__
self.ssl_options['certfile'])
ValueError: certfile "/Users/leigh/mycert.pem " does not exist

"/Users/leigh/mycert.pem" 是 mycert.pem 在我本地笔记本电脑上的路径。

我有没有听错 D:? 试图解决这个问题几个小时,但不知道发生了什么...... 非常感谢任何人都可以让我知道如何解决这个问题..

我认为您没有使用正确的证书文件 - 文件本身应该在您的实例上,而不是在您的 "local laptop"。

将它移动到您的实例,找到它的位置,然后更新您的 jupyter_notebook_config.py 文件。

将密钥和证书生成到 jupyter 配置文件夹中:

openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout ~/.jupyter/key.key -out ~/.jupyter/cert.pem

编辑 ~/.jupyter/jupyter_notebook_config.py 并添加:

import os
c.NotebookApp.keyfile = os.path.expanduser('~') + '/.jupyter/key.key'
c.NotebookApp.certfile = os.path.expanduser('~') + '/.jupyter/cert.pem'

使用cert.pem代替key.key

openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout ~/.jupyter/cert.pem -out ~/.jupyter/cert.pem

还要确保检查 cert.pem 的权限。您可能必须为此使用此命令 sudo chmod 777 cert.pem