Fix Permissions for Private Key are Too Open with SSH
Last modified on .
The default file permission on Linux is 777
, which means everyone can read, write and execute the file. It's fine for most of the scenario, but it's another story when it comes to SSH private key. If you try to establish an SSH connection with a too open private key, WARNING: UNPROTECTED PRIVATE KEY FILE!
will be shown.
Solution
To solve the problem is quite easy, simply change your SSH private key's permissions.
In the following, we will take
~/.ssh/id_rsa
as an example, change it to your actual key path.
Read Only (Recommended)
Change it to only readable by the owner:
$ sudo chmod 400 ~/.ssh/id_rsa
Read and Write
Or grant read and write permissions to the owner:
$ sudo chmod 600 ~/.ssh/id_rsa