POSTS / Fix `~/.ssh/authorized_keys` Not Working Issue
#48 says you need to run chmod 644 ~/.ssh/authorized_keys
to allow the SSH server read the private keys successfully, but it doesn’t work. 😅
This post says that 644
is not the correct permissions for ~/.ssh/authorized_keys
.
This is what he did after finding the ~/.ssh/authorized_keys
not working.
- Run
journalctl --unit=sshd
and see what happened during the last connection. - Find SSHD complaining
Authentication refused: bad ownership or modes for directory ~/.ssh
. - Run the following code to set correct permissions:
cd ~/.ssh chmod 700 ../ chmod 700 . chmod 600 ./authorized_keys
Then I found this from Ubuntu Community Help Wiki for detailed information: Permission Denied, which says:
If you’re sure you’ve correctly configured
sshd_config
, copied your ID, and have your private key in the.ssh
directory, and still getting this error:Permission denied (publickey)
. Chances are, your/home/<user>
or~/.ssh/authorized_keys
permissions are too open by OpenSSH standards. You can get rid of this problem by issuing the following commands:chmod go-w ~/ chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys
And the correctness of the solution above gets validated.