Wrong Permissions on authorized_keys Blocks Git Access via SSH
Why an accidental chmod 666 on the git user's authorized_keys file forced a password prompt over SSH, and how restoring 600 permissions fixed public-key authentication.
During playing around with a hosted Git environment I ran into an issue where access to the remote requested the password for the git user.
git@12.34.56.78's password:
Permission denied (publickey,password).
fatal: Could not read from remote repository.
The reason was accidentally changed permissions (666) of the key file ~/.ssh/authorized_keys.
-rw-rw-rw- 1 git git 393 Feb 12 21:41 authorized_keys
After setting it back to 600
chmod 600 authorized_keys
ls -la
-rw------- 1 git git 393 Feb 12 21:41 authorized_keys
the remote didn’t request any password and used the authentication via public key.