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:
(1) Check whether the PubKeyAuthentication is enabled on the sshd conf of the remote server.
(2) Confirm that the remote server is added with the remote username "root".
(3) Reset the fingerprint of the remote Server.
After resetting try to reset sshd and try to re-login to ezsh.
root@ubuntu:~# systemctl restart sshd
Check the latest SSH logs for any errors.
If the remote server is Ubuntu --> root@ubuntu:~# tail -f /var/log/auth.log
If the remote server is CentOS --> root@ubuntu:~# tail -f /var/log/secure
Run the following command to see which key types are enabled on the server.
root@ubuntu:~# 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..
root@ubuntu:~# echo "PubkeyAcceptedKeyTypes ssh-rsa" >> /etc/ssh/sshd_config
Re-run the below command and confirm that ssh-rsa has been enabled.
Related Articles:
Add ssh pubkey for passwordless authentication in ssh