Disable #password authentication in #Ubuntu 24.04 LTS
Ever tried to disable password based authentication and only allow key based authentication on your Ubuntu servers ? Following is the common instruction.
sudo nano /etc/ssh/sshd_config
PasswordAuthentication no
PubkeyAuthentication yes
then restart SSH service
But - it will not work !!! You can still authenticate using password. Try that if you don't believe me.
Hey, don't stress - what is the solution ? Surely edit those settings in /etc/ssh/sshd_config and save. Then
sudo nano /etc/ssh/sshd_config.d/50-cloud-init.conf
PasswordAuthentication no
Now save and restart ssh and it will work. So simple - right ?