Skip to Content

Why Key Authorization is not working?

Why Is Key Authorization Not Working?

In case, after configuring the server and adding the global key to /root/.ssh/authorized_keys, why is it still asking for a password when attempting to log in?

Go through the following Troubleshooting steps:

  • Check whether the PubKeyAuthentication is enabled on the sshd conf of the remote server.

[email protected]:~# sshd -T | grep -i ’PermitRootLogin\|PubkeyAuthentication’

  • Confirm that the remote server is added with the remote username "root".

  • Reset the fingerprint of the remote Server.

After resetting try to reset sshd and try to re-login to ezsh.

[email protected]:~# systemctl restart sshd

  • Check the latest SSH logs for any errors.
  • Run the following command to see which key types are enabled on the server.

[email protected]:~# sshd -T|grep -i key

pubkeyacceptedalgorithms [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256

               Add ssh-rsa to sshd conf in the remote server. 

In Ubuntu 22, ssh-rsa is disabled by default, so you need to enter it manually..

[email protected]:~# echo "PubkeyAcceptedKeyTypes ssh-rsa" >> /etc/ssh/sshd_config

               Re-run the below command and confirm that ssh-rsa has been enabled.

[email protected]:~# sshd -T | grep -i key

pubkeyacceptedalgorithms [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa

Related Articles

Add ssh pubkey for passwordless authentication in ssh

Authentication by ssh key failed

Error log file and config file to troubleshoot