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.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
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 ec2-user@EC2-INSTANCE-DNS.compute.amazonaws.com


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! 

Comments

Unknown said…
Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
AWS Online Training
gowsalya said…
Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
AWS training in chennai
Unknown said…
Great Article android based projects

Java Training in Chennai

Project Center in Chennai

Java Training in Chennai

projects for cse

The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

Popular posts from this blog

3 Must Haves of a Status Report

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

Configure hosts File in Android