Disable #password authentication in #Ubuntu 24.04 LTS

Krishnendu Paul

Mar 25, 2025 1 min read


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 ?



Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.