Skip to content

[Solved][Linux] Permissions 0777 for '/home/clay/.ssh/id_rsa' are too open.

Last Updated on 2022-06-29 by Clay

Recently, I configured my own SSH key on another server. The purpose is to hope that the code written with others on the other server can be pushed to GitHub for version control through git commands.

In order to share the same set of keys with them (a weird way I tried...) I directly set the id_rsa file permission of the automatically generated key to 777.

However, the permission of 777 means that this file is readable, writable and executable for everyone, and even many predecessors who use Linux will call for never using 777 to grant file permissions.

Back to the topic. Today, even when I used the git push command, I encountered the following error:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@adaw132547
Permissions 0777 for '/home/clay/.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.
Load key "/home/clay/.ssh/id_rsa": bad permissions
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.


Simply put, the private key file permissions I set are too open, and the system pops up a warning and prevents me from continuing to do so.


Solution

The solution is very simple, you can refer to [Linux] Use “chmod” Command to Change the File Permissions to change file permissions.

The minimum required permission actually only needs to be readable by the owner (that is yourself), so we can directly set the permission 400:

chmod 400 ~/.ssh/id_rsa


In case there is a need to edit in the future, use:

chmod u+w ~/.ssh/id_rsa


to add read and write permissions. Of course, if you want to do it in one step, you can directly modify this file to be readable and writable by the owner.

chmod 600 ~/.ssh/id_rsa


By the way, I am not familiar with Windows terminal commands (that is one of my future study goals), but it is said that just changing chmod to chgrp will work.


References


Read More

Tags:

Leave a Reply