Jupyter notebook permission denied, unable to save - amazon-web-services

I am having permission denied for Jupyter notebook running on Ubuntu, AWS E2 instance. Below is the image for the error
I have tried to use other browser, reinstall it and clear cache. None of it works.

If your notebook is configured with some auth code (generated by notebook by default), and you've cleared your cache, and cookies, you will get the screen similar to below:
Here you can use the token shown in terminal, while running the notebook, the log will be similar to the below:
To access the notebook, open this file in a browser:
file:///home/ubuntu/.local/share/jupyter/runtime/nbserver-19740-open.html
Or copy and paste one of these URLs:
http://ip-123-1-1-123:8888/?token=abcdefghijl
or http://127.0.0.1:8888/?token=abcdefghijl
and if you want to run notebook without authentication you can run the below command:
jupyter notebook --ip='0.0.0.0' --NotebookApp.token='' --NotebookApp.password=''
Also try creating a new notebook, instead of accessing the Test.ipynb again, so that you can figure out if the issue is from the specific file or whole server.

The main reason is i don't have the permission to overwrite the file. First of all, i create the file at /home/ubuntu, which I don't have permission of. So i create a folder to store the file inside it. Other than that, i also done quite a lot modifications including adding the inbound rules and the permissions, i think some of it did help. I list out some of the website i think is very useful in tackling this issue:
PermissionError: [Errno 13] Permission denied: Cannot open Jupyter on Browser despite running correctly on AWS EC2 instance
https://stackoverflow.com/questions/53097180/permissionerror-errno-13-permission-denied-when-accessing-to-aws-ec2#:~:text=Make%20sure%20you%20type%20https,with%20version%2070%20or%20newer.

Related

Unable to connect google compute engine, getting permission denied error

I have accidentally changed permission of the .ssh folder to 600 and now I am not able to log in to the GCP server through SSH as it's giving me permission denied error.
**Connection Failed**
You cannot connect to the VM instance because of an unexpected error. Wait a few moments and then try again.
I tried multiple options like, ssh troubleshooting instance, enabling serial console, ssh private key login.
Thanks you in advance.
One of the simple ways to fix this would be to use a startup script. In this script just execute chmod 700 /path/to/your/.ssh.
The startup scripts are executed with root privileges, so it should be able to fix your problem with .ssh folder permissions.
So, what you need to do:
Set the startup script.
Restart the VM.
Wait a minute or two to make sure the script got executed.
Remove the startup script from the machine. (no need to restart again)
Thank you guys for all your support, my problem got solved by follwing below document:
Serial Console with local password using a startup script

Unable to connect to Huggingface from EC2 instance

I am running a python code in EC2 instance where I am loading a Huggingface model using the from_pretrained() method. I get the error
OSError: Couldn't reach server at 'https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-uncased-config.json' to download pretrained model configuration file.
while trying to initialize the reader. To get over this, I downloaded the file manually and provided the local JSON path. That worked fine but then I see issues in loading the tokenizer too.
OSError: Couldn't reach server at '{}' to download vocabulary files.
I think my network settings of EC2 are not correct due to which I am unable to connect to external Huggingface repository.
I tried relaxing the inbound rules for EC2 to IP version|Type|Protocol|Port range|Destination=>IPv4|All|traffic|All|All|0.0.0.0/0 but even that doesn't help. The outbound rules are already IPv4|All|traffic|All|All|0.0.0.0/0.
I also tried creating an IAM role with policy AmazonS3ReadOnlyAccess and attached it to the EC2 instance but still getting the same error.
Could someone point what needs to be done to solve this. Thanks.
Here is how i fixed this issue.
i installed pyopenssl like this :
!pip install pyopenssl
then i restarted terminal and re-ran the code and it fixed the issue for me,thanks
might be your network is using proxy
this might help
$ proxies = {"http": 'foo.bar:3128', addyourproxy:'foo.bar:4012'}
$ from transformers import pipeline
$ qt_ans = pipeline('question-answering')

AWS educate Ec2 public key error after 1-2 weeks?

I have been using AWS educate for an ec2 instance that I connect using terminal on my macbook pro Catalina. I use ubuntu to connect (I have putty running on terminal) and I have been able to connect perfectly fine and changed nothing, but after about a week or 2 when I use the command
sophiadhanani$ ssh -i "name of pem file.pem" ubuntu#ec2-IPnumbers.compute-1.amazonaws.com it returns permission denied (publickey).
No idea why this is happening and the trouble shoot says to create a temp instance and then mount point- is there an easier way to solve this issue?
Are you using an encrypted home directory on your Macbook?
Apparently, using an encrypted home, you can experience login problems.
You may want to remove the file from ~/.ssh/authorized_keys to somewhere else e.g. /etc/ssh/.authorized_keys
And then edit your the /etc/ssh/sshd_config file and add /edit to point to the new location.
AuthorizedKeysFile /etc/ssh/.authorized_keys

Permission denied to read datadog.yaml file

I've installed the datadog app on my linux vm but i can't seem to read the datadog.yaml agent file.
[ Error reading /etc/datadog-agent/datadog.yaml: Permission denied ]
My linux box is hosted on GCP, do i need to configure permissions?
you can open it by navigating to the directory it is in, and then typing
sudo nano datadog.yaml.
You need root permissions to view the file as far as I know.

AWS EMR jupyter password

im using EMR and wanted to use jupyter(ipython) so i added to the cluster the bootstrap action:
s3://elasticmapreduce.bootstrapactions/ipython-notebook/install-ipython-notebook
I performed the port tunelling to access jupyter from my local host and works fine, but it is asking for a login password, tried empty, tried hadoop, but no luck, does any body knows what is the jypyter password?
I ran into this problem as well when I used the same bootstrap action. I tried adding in Args=[--password, jupyter] which I also could not get working. That was from this aws forum:
Name='Install Jupyter notebook',Path="s3://aws-bigdata-blog/artifacts/aws-blog-emr-jupyter/install-jupyter-emr5.sh",Args=[--r,--julia,--toree,--torch,--ruby,--ds-packages,--ml-packages,--python-packages,'ggplot nilearn',--port,8880,--password,jupyter,--jupyterhub,--jupyterhub-port,8001,--cached-install,--notebook-dir,s3://<your-s3-bucket>/notebooks/,--copy-samples]
What I did instead was to follow these instructions for installing anaconda directly in the EMR instance using the CLI. If you follow the first part you should be able to get it up and running. To summarize here:
ssh into your master emr instance using the .pem file you saved
once there's you'll want to install anaconda using super user priveledges: sudo wget http://repo.continuum.io/archive/Anaconda3-4.1.1-Linux-x86_64.sh. Then bash Anaconda3–4.1.1-Linux-x86_64.sh
Make sure you're using the anaconda version of python: which python
If you're not, specify your source: source .bashrc
Now make a jupyter config file: jupyter notebook --generate-config
cd into the jupyter folder: cd ~/.jupyter/
update the config file: vi jupyter_notebook_config.py
In the config file add the following lines:
c = get_config()
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 6789 <---pick whichever port you want
exit out of the config editor and run jupyter via: jupyter notebook
this should run a notebook with no active kernels (for now). But it will give you the token you're looking for: http://localhost:6789/?token=xxxxxx
Leave this running, and open a new terminal window. Now you'll want to tunnel to the EMR instance per this aws blog post (make the port the same as the one you specified in the config file). ssh -o ServerAliveInterval=10 -i <<credentials.pem>> -N -L 8192:<<master-public-dns-name>>:8192 hadoop#<<master-public-dns-name>>
Opening localhost:6789 in the browser should prompt you with the jupyter page to enter your password or token. Enter the token that was generated in the above step and you should be good to go.
Hope this helps! There might be a less convoluted way, but this is what ended up working for me.