SSH error: permissions are too open

When working with SSH’s private/public key pair, users often come across the following error:

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

Here, '~/.ssh/id_rsa' can be replaced with the path to the user’s private key.

Why does this error show up?

This error is meant to inform users that the permissions for their private key need to be changed and made more secure. As the name implies, a private key must be kept private and is only accessible to the user themselves.

Solution

Luckily for us, we can update the permissions with the help of some simple chmod commands.

If we want our private key to be readable by the logged in user, we will use the following command:

chmod 400 ~/.ssh/id_rsa

If we want our private key to be both readable and writable by the logged in user, we will use this command instead:

chmod 600 ~/.ssh/id_rsa

For windows, when you download the key file, make sure you move to the directory with Sudo privileges, i.e., in the C user directory.

svg viewer

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved