Unprotected Private Key File, Permissions 0644 for ‘yourFile.pem’ Are Too Open

Unprotected Private Key File, Permissions 0644 for ‘yourFile.pem’ Are Too Open

So, I’m new to AWS. Today I setup a new EC2 instance to deploy a personal instance of sentry.io. It’s a pretty universal and open source code error reporting tool which I plan to use to report on internal infrastructure and customer facing applications. During that setup process I needed to SSH into my new EC2 server and setup NGINX. I got the unprotected private key file, Permissions 0644 for ‘yourFile.pem’ are too open. Do note that this problem was solved on a mac so you windows guys are probably out of luck if you’re experiencing the same thing.

My Computer Setup

  • macOS

My Command

ssh -i yourFile.pem  username@publicIpAddress

You’ll get yourFile.pem during the initial setup of the EC2 instance. The username and ip address should have been created during that initial setup process also which is outside of the scope of this quick post so sorry for not covering that.


Permissions 0644 for 'yourFile.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 "Sentry.pem": bad permissions
ubuntu@ipaddress: Permission denied (publickey).


This problem had a quick and easy fix. You just had to change the permissions on the pem file using the following command.

chmod 400 /Users/yourUserName/pathToYourFile/fileName.pem

This command will make the file read only and remove all other permissions on the file. You should no longer get the error message when you try to SSH into your EC2 instance now. Check out some this post for more bash stuff. Happy coding!

Leave a Comment