AWS EC2 Permission denied (publickey,gssapi-keyex,gssapi-with-mic

Issue:

 ssh -i "key-aws.pem" ec2-user@ec2-IP.compute-1.amazonaws.com

IP: 10.0.0.1

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for key-aws.pem are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: key-aws.pem
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

[vagrant@vagrant-centos65]$ chmod 400 key-aws.pem
[vagrant@vagrant-centos65]$ ls -ltr key-aws.pem
-r-xr-xr-x 1 vagrant vagrant 1692  key-aws.pem

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0555 for 'key-aws.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: key-aws.pem
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

Solution:

Follow the below steps and it will resolved for sure;
1. Copy the key-aws.pem into /home/vagrant/.ssh/
    cp key-aws.pem /home/vagrant/.ssh/
2. Change the file permission to read for that user only.
     chmod 400 /home/vagrant/.ssh/key-aws.pem
     [vagrant@vagrant-centos65]$ ls -ltr /home/vagrant/.ssh/
     -r-------- 1 vagrant vagrant 1692 key-aws.pem
3. Execute ssh command now.
    ssh -i "/home/vagrant/.ssh/key-aws.pem" ec2-user@ec2-IP.compute-1.amazonaws.com   

Happy learning and implementation!!

7 comments:

  1. Decent post. I learn something absolutely new and testing on sites I earthcycle consistently. It's consistently valuable to peruse articles from different writers and work on something from different destinations.

    ReplyDelete
  2. Decent post. I learn something absolutely new and testing on sites I earthcycle consistently. It's consistently valuable to peruse articles from different writers and work on something from different destinations.

    ReplyDelete
  3. Thank you for your post, I look for such article along time, today i find it finally. this post give me lots of advise it is very useful for me.
    AWS Training in Chennai

    ReplyDelete

Please provide your input, it will honer for me...