WARNING: UNPROTECTED PRIVATE KEY FILE!

If you try to copy your .ssh private keys from one machine to another, then you might see this error. You probably forgot to set correct permissions on your private key after copying the key to .ssh directory. It’s very important that these files be protected from any unauthorized access. Only owner of the key should be allowed access to the key files.

The complete error message:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for '/home/sumitc/.ssh/id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /home/sumitc/.ssh/id_rsa

To fix this, you’ll need to reset the default permission on key files.  We can do this by resetting the permissions back to 600. That means only owner has read/write permissions to the key file.

sudo chmod 600 ~/.ssh/id_rsa
sudo chmod 600 ~/.ssh/id_rsa.pub

This should fix the permission error, and you should be able to do a ssh session correctly.

One thought on “WARNING: UNPROTECTED PRIVATE KEY FILE!

Leave a comment