Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

SSH unprotected private key file error

📅 2016-May-11 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ error, ssh ⬩ 📚 Archive

Problem

I tried to SSH to a server using a private key file and got this error:

$ ssh -i myprivate.key 10.0.0.100
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0664 for '/home/joe/myprivate.key' 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: /home/joe/myprivate.key

Solution

This key file strangely had access permissions by all to read, write and execute! SSH was complaining that such a file is too open and could be compromised. I reduced the access permissions to just read by me:

$ chmod 0400 myprivate.key

SSH worked after this change 😊

Tried with: SSH 6.6 and Ubuntu 14.04