Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PermissionError: [Errno 13] Permission denied when accessing to aws ec2

I have ubuntu 16.04 running on virtual box(on mac), and on aws ec2 ubuntu 18.04 running. I am trying to run Jupiter notebook on aws.ec2 and trying to access it remotely thru my web browser on my local Ubuntu. I am able to access remote ubuntu(aws.ec2) terminal. After I followed the steps on this link

I got the following error on the step 9.

I reinstalled everything from scratch 3 times(including local ubuntu and aws ec2 instance), but no progress so far.

Last login: Thu Nov  1 06:34:07 2018 from 134.1****
ubuntu@ip-172-***:~$ export XDG_RUNTIME_DIR=""
ubuntu@ip-172-***:~$ jupyter notebook
[I 06:40:19.525 NotebookApp] Serving notebooks from local directory: /home/ubuntu
[I 06:40:19.528 NotebookApp] The Jupyter Notebook is running at:
[I 06:40:19.528 NotebookApp] https:// **** :8888/?token=727fbb120d19f55a435c1*****
[I 06:40:19.528 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 06:40:19.529 NotebookApp]

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        https://(ip-172-31-***** .0.1):8888/?token=727fbb120d19f55a435c14*********
ERROR:asyncio:Exception in callback BaseAsyncIOLoop._handle_events(4, 1)
handle: <Handle BaseAsyncIOLoop._handle_events(4, 1)>
Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/events.py", line 145, in _run
    self._callback(*self._args)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tornado/platform/asyncio.py", line 122, in _handle_events
    handler_func(fileobj, events)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tornado/stack_context.py", line 300, in null_wrapper
    return fn(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tornado/netutil.py", line 262, in accept_handler
    callback(connection, address)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tornado/tcpserver.py", line 263, in _handle_connection
    do_handshake_on_connect=False)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tornado/netutil.py", line 565, in ssl_wrap_socket
    context = ssl_options_to_context(ssl_options)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tornado/netutil.py", line 540, in ssl_options_to_context
    context.load_cert_chain(ssl_options['certfile'], ssl_options.get('keyfile', None))
PermissionError: [Errno 13] Permission denied
ERROR:asyncio:Exception in callback BaseAsyncIOLoop._handle_events(4, 1)
handle: <Handle BaseAsyncIOLoop._handle_events(4, 1)>
Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/events.py", line 145, in _run
    self._callback(*self._args)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tornado/platform/asyncio.py", line 122, in _handle_events
    handler_func(fileobj, events)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tornado/stack_context.py", line 300, in null_wrapper
    return fn(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tornado/netutil.py", line 262, in accept_handler
    callback(connection, address)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tornado/tcpserver.py", line 263, in _handle_connection
    do_handshake_on_connect=False)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tornado/netutil.py", line 565, in ssl_wrap_socket
    context = ssl_options_to_context(ssl_options)
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tornado/netutil.py", line 540, in ssl_options_to_context
    context.load_cert_chain(ssl_options['certfile'], ssl_options.get('keyfile', None))
PermissionError: [Errno 13] Permission denied

Note1: on ec2 instance, Ubuntu has 18.04 version and it came with python 3.6.3 then I have to install anaconda on the top of it and then the python version now is 3.5.2 once I typed $python3.

Note2: Despite after the anaconda has been installed into the EC2 then the python version degraded to 3.5.2

once I have checked the following directory /usr/local/lib/ there only python3.6 folder is existing, then I typed $sudo chmod 777 dist-packages/

then $jupyter notebook, then copy the token link and combine with dns, but still didn't worked.

like image 539
hkacmaz Avatar asked Dec 14 '22 14:12

hkacmaz


1 Answers

I had the same problem, and now I just solved it by trying a couple things. Try these solutions to see if it helps:

  1. Changed the ownership of the /home folder and ~/.local/share/jupyter/ folder to current user running this command:
   sudo chown -R $USER /home/

   sudo chown -R $USER ~/.local/share/jupyter/
  1. If you encounter ssl error problem, check out this link.

  2. Make sure you type https://<jupyter-server-ip> in your browser instead of http://.

  3. If you have Your connection is not private problem in your chrome and can not proceed, try safari or other browsers. This happens in chrome with version 70 or newer.
  4. Try Leon Huang's solution to turn on the port 8888 for your instance.
like image 93
Novus Avatar answered Dec 16 '22 04:12

Novus