Troubleshooting - AWS EC2 - "Load key '/documents/awskey.pem' : bad permissions

Problem:

This error is encountered when attempting to connect to an EC2 instance via SSH with a .pem file that doesn’t have the appropriate linux filesystem permissions in place.

Recommended Fix:

  • CD to the directory where the file exists

  • Type : sudo chmod 400 <filename>

The next time you run ssh it should work.

Background:

I ran into this issue on a Macbook Pro running OS X. My file permissions were “too open” for use. The file permissions before I made the change were set to 0644 which threw the error.