AWS warning unprotected private key file while connecting to EC2 instance

If you are trying to creating an ssh connection to AWS EC2 host from your .pem file, you may get the following error the first time you download the .pem file from AWS console.

Permissions 0644 for 'node.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 "my-key-pair.pem": bad permissions
Permission denied (publicly).

This warning shows up if your .pem file does not have enough restriction for non-owners. Therefore, you need to change the permission on the local file. Use the following commend to set permission on file to be readable only by owners but no-one else.

> chmod 400 /path/my-key-pair.pem

After running the command above, you can connect to your EC2 instance through SSH.

> ssh -i /path/my-key-pair.pem

AWS EC2 OS AWS User Name
Amazon Linux ec2-user
Ubuntu ubuntu
Fedora fedora
RHEL5 root or ec2-user
SUSE root or ec2-user

Happy coding! 


Popular posts from this blog

Space Character Problem on IE 6, 7, and 8

AWS encryption chart (SSE-S3 vs SSE-KMS vs SSE-C)

Does Netflix work on iOS 5 Beta 4?