Unable to connect to EC2 instance from windows

Viewed 1174

I am on windows 10. I have launched an EC2 instance on AWS and downloaded pem file for it. I am trying to connect to the instance from terminal. When I run command:

ssh -i "mykey.pem" ec2-user@<ip>

I get error:

Permissions for 'mykey.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "mykey.pem": bad permissions
<ip>: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

Based on some online suggestions, I ran following command for the key file using cygwin:

chmod 400 mykey.pem

But I still see same error.

What do I need to get it working?

3 Answers

Go to your pem file > Right Click > Select Properties > Go to Security Tab > Click On Advanced. Then you will see this UI

enter image description here

Then remove all the entries from the permission entries. If you are unable to remove the entries because of inheritance click on the button called disable inheritance and then remove all the entries.

Then click on Add button > Select Principal > Click On Object Type > Only Select Users > Click OK > Then Click On Advanced button > Find Now > then select the user ( the user here should be the same as the owner of the pem file ) > Give him all the permissions > and apply all the changes enter image description here enter image description here Click OK after selecting users only enter image description here Make sure you select the owner of the file in my case BASANTA KC enter image description here Give the permission. ok & apply then :) enter image description here

Could you try viewing the permissions with ls -l and see if it has the appropriate permissions.

Could you also try the following:

  1. Right click on the mykey.pem file and click on security and remove all permissions.
  2. Also click on Advanced & Disable inheritance.
  3. Then give the appropriate permissions and try again.
Related