I have launched a new Linux instance in my AWS account and downloaded the private key file. As we all know, AWS only allows default key-based SSH authentication. When I tried to SSH with the downloaded private key file, I got the a warning message Permissions 0644 for ‘server.pem’ are too open and it prompted for the password.
In this faq, you will learn to fixe WARNING: UNPROTECTED PRIVATE KEY FILE! error in Linux.
The Problem:
The error looks like the below:
ssh -i server.pem [email protected]
Output@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 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 [email protected]'s password:
I was aware of this issue, so I got it fixed easily. If we read the error message carefully, we will understand that there are some issues with the permissions on the server.pem file.
So this tutorial is for our readers to quickly solve this issue without wasting their time. Thanks
The Solution:
As per security policy, the private key file must not be publicly viewable in order to successfully log in to the server using SSH protocol. So you need to change the file permissions to restrict access to the owner only. The owner only required the read permission to use this file during an ssh connection. Change the file permissions with the following command:
chmod 400 server.pem
Now try to ssh with the same command and same key file.
ssh -i server.pem [email protected]
You will be able to ssh properly to the remote server without any error message.