Wednesday, 17 April 2019

How to resolve UNPROTECTED PRIVATE KEY FILE issue during SSH of EC2 Server by Raj Gupta

If we get WARNING: UNPROTECTED PRIVATE KEY FILE! when trying to SSH into Amazon EC2 Instance



 If your private key can be read or written to by anyone , then SSH ignores your key and you see the below error

[root@ip-172-31-91-224 ~]# ssh -i rajkp.pem ec2-user@ec2-54-91-231-121.compute-1.amazonaws.com

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0774 for 'rajkp.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 "rajkp.pem": bad permissions
Permission denied (publickey).

Its is due to our key pairs are open to other

[root@ip-172-31-91-224 ~]# ll
total 4
-rwxrwxr-- 1 root root 1671 Apr 17 08:41 rajkp.pem


So resolve this issue we need to change the permission of this key pair file.

[root@ip-172-31-91-224 ~]# chmod 700 rajkp.pem

[root@ip-172-31-91-224 ~]# ll
total 4
-rwx------ 1 root root 1671 Apr 17 08:41 rajkp.pem

Now if do SSH then its fine 

[root@ip-172-31-91-224 ~]# ssh -i rajkp.pem ec2-user@ec2-54-91-231-121.compute-1.amazonaws.com

       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-ami/2018.03-release-notes/
14 package(s) needed for security, out of 21 available
Run "sudo yum update" to apply all updates.
[ec2-user@ip-172-31-82-122 ~]$ 


1 comment:

  1. Hello everyone , here’s your opportunity for you to achieve your dreams of being a multi million dollar rich through trading , I once loss all I got through trading but was fortunate to come across a woman with great virtue and selfless heart (Mary ) i was introduce to her masterclass strategy while searching online which has revived me of all my losses and made me gain more and more . With her unique strategy you are entitled to daily signals and instant withdraw ,be rest assured of getting a refund of all your loss investment with any platform that has denied you in one way or the other in getting your money . Mrs Mary masterclass strategy is simply the best for beginners and those that are finding it difficult to succeed through trading she’ll help you with just a simple step . Email her ( maryshea03 @ Gmail .com) WhatsApp +1 562 384 7738 . Remember this is absolutely free!!!

    ReplyDelete