AWS Permissions are too open error when trying to connect to EC2

By | March 9, 2020

If you are trying to connect to an EC2 instance in AWS and you get the following permission error saying that your key file is too open….

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'awskeypair.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 "awskeypair.pem": bad permissions

 

The way to get around this is to chmod the file to 400. That is:

> chmod 400 "your pem file"

You are almost guaranteed to get this error because when you download the key pair .pem file, the default permission will be “-rw r– r–“. The first 3 characters shows the permission of the user who owns the file. The middle 3 shows the group permission and the last 3 characters shows permissions for anyone not in the first 2 categories. So this is saying that the user can read and write, members of your group can read and all others can read. This is too open.

Changing it to 400 will result in “-r- — —” which means that only the user can read the file, and no other groups or users have any sort of access.

 

 

Category: AWS

One thought on “AWS Permissions are too open error when trying to connect to EC2

Leave a Reply

Your email address will not be published. Required fields are marked *