Solve UNPROTECTED PRIVATE KEY FILE! Permissions 0777 for ‘.pem’ are too open

Often you may not be able to login to your new server using the SSH key. The error message looks something like this. UNPROTECTED PRIVATE KEY FILE! Permissions 0777 for ‘filename.pem’ are too open.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for 'default.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 "default.pem": bad permissions

How to fix UNPROTECTED PRIVATE KEY issue?

This is basically file permission problem, the server doesn’t want you to expose your SSH key to everyone for better security. If you give full permission to the file, it can be stolen and your server might get compromised.

So to protect your server, you gotta protect the SSH file. To do so, select the SSH Key file and open permission menu.

In Ubuntu OS

  1. locate  the file and right click on it
  2. Select properties and then permission
  3. For owner, set the permission to Read-only
  4. For group and others, set it to none
  5. Also disable the execute function

 

The same thing applies for Windows and other OS. Basically you have to set the SSH key permission to read only and disable execute function. That’s all! Retry connecting to the server using the Key and now that should work fine 😉

Leave a Comment