SSH with Private Key – WARNING: UNPROTECTED PRIVATE KEY FILE

Recently I have created a new instance on AWS using Ubuntu 14.04 LTS AMI. As we know AWS allows key based login by default. When I tried to SSH with downloaded server.pem key, I got following warning message on-screen and then it prompts for password of user.

Error:

$ ssh -i server.pem ubuntu@remote-server.com  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0644 for 'server.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: server.pem ubuntu@remove-server.com's password:  
As I was aware about this issue, So I got it fixed easily. If we read error message carefully, we will understand that there are some issues with the permissions on server.pem file.

Solution:

As per security policy your private key file must not be publicly viewable in order to successfully login to server using SSH protocol. So Change the file permissions to restrict it access to owner only. Use following command to do it.
$ chmod 400 server.pem 
Now try to ssh with same command with same key file.
$ ssh -i server.pem ubuntu@remote-server.com 
You will be able to ssh properly to server using same private key.

Thanks for Visit Here

Comments