SSH Key Permissions

security

It’s important to set the permissions on .ssh folder. If you allow too much access your connection will be refused. If you don’t have enough permissions you may lock yourself out.

The below script works for setting the folder and private/public key pairs in the folder:

chmod 700 ~/.ssh
chmod 644 ~/.ssh/authorized_keys
chmod 644 ~/.ssh/known_hosts
chmod 644 ~/.ssh/config
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
chmod 600 ~/.ssh/any_other_private_key
chmod 644 ~/.ssh/any_other_public_key.pub

Resources