Error message:
david@daniel-Inspiron-531:~$ ssh-add david/.ssh/id_rsa
@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0775 for ‘david/.ssh/id_rsa’ are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
david@daniel-Ins
Understanding id_rsa Private Key File
~/.ssh/id_rsa Contains the private key for authentication. These files contain sensitive data and should be readable by the user but not accessible by others (read/write/execute). ssh will simply ignore a private key file if it is accessible by others. It is possible to specify a passphrase when generating the key which will be used to encrypt the sensitive part of this file using 3DES.
How to Fix UNPROTECTED PRIVATE KEY FILE
It is required that our private key files are NOT accessible by others. Permissions 0755 for private key file are too open. This private key will be ignored.
Check the permission of private file
- ls -lrt ~/.ssh/id_rsa
- ls -lrt ~/.ssh/id_rsa.pub
Change the private key file permission
- sudo chmod 600 ~/.ssh/id_rsa
- sudo chmod 600 ~/.ssh/id_rsa.pub
Login remote server with private key
- ssh -i ~/.ssh/id_rsa user@server_ip
Keep in mind that if we keep all of our keys in the ~/.ssh directory (or any other directory), we may need to adjust the permissions for that directory as well. In that case, use this:
- $ sudo chmod 755 ~/.ssh