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.
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
Happy coding!
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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