WARNING: UNPROTECTED PRIVATE KEY FILE!

11 October 2019

I was planning to do a clean install after macOS Catalina was released. I copied my ssh keys and I’ve seen the warning when I tried to run git-related commands.

After a short research, I’ve found out the source of the problem is the permissions on the private key file.

Complete error output:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@     WARNING: UNPROTECTED PRIVATE KEY FILE!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/Users/erdaltsksn/.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 "/Users/erdaltsksn/.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.

To fix this, you need to reset the permission to default.

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

Finally, you may need to adjust the container directory permissions as well:

chmod 755 ~/.ssh

That’s all. Now you can use your SSH keys without any errors or warnings.

! Please note that this is not a specific issue to any operating system. This is a security issue related to OpenSSH client.

Tags: devops ssh fix