SSH: "Permissions 0644 for 'my_key.pub' are too open."

45,687

Solution 1

You may be running ssh-keygen on the wrong file. ssh-keygen -y operates on a private key file. ".pub" files normally contain the public key. You probably have a file there named my_key, without any extension, and it ought to be mode 0600. That is the file which should contain the private key.

To directly answer your question, SSH keys are normally used to permit connecting to remote servers without a password. Possession of the private key would permit someone to log into your account on any system which accepts the key. ssh-keygen and the other ssh utilities require private key files to have restricted permissions because the files are sensitive and need to remain secure.

Solution 2

The only command you need to run is chmod 600 ~/.ssh/id_rsa. That's it.

This changes the permissions on the file so that the owner (you) can read and write it, which will remove the error message you receive.

Solution 3

0644 in not supposed to be too open for a public key, but is too open for your private key.

Your private key should have permission 0600 while your public key have permission 0644.

By the way, you should also take care of the permission on .ssh folder. It should has the permission 0700, so that only you, the owner, has control over the folder.

As to your home directory, write permission is not supposed to be granted to group and others.

Run chmod go-w /home/username should fix that.

Share:
45,687

Related videos on Youtube

user2820379
Author by

user2820379

Updated on September 18, 2022

Comments

  • user2820379
    user2820379 over 1 year

    Why is 0644 i.e. -rw-r--r-- too open for a SSH key? Also I could not find any false permissions on the .ssh directory (0700) or the home directory (0731).

    Btw I'm getting this error when testing the paraphrase of a key via ssh-keygen -y -f my_key.pub

    Best regards

  • niftylettuce
    niftylettuce over 6 years
    Absolutely do not follow these instructions. This is NOT what you should do. This will also reset all home directory permissions. You should ONLY be modifying the .ssh folder and the id_rsa file itself, not your entire home directory!