Disabling password authentication not working

dk flag

On a Ubuntu 22.04 machine, I'm trying to disable password authentication. To achieve that, I have updated /etc/ssh/sshd_config from

# PasswordAuthentication yes


PasswordAuthentication no

And then restarted sshd with sudo systemctl restart ssh.

However, password authentication is still working.

Am I missing anything here?

On the machine, it's installed OpenSSH_8.9p1 Ubuntu-3ubuntu0.1, OpenSSL 3.0.2 15 Mar 2022.

je flag

Not sure if I missed it earlier or if it is new. Now /etc/ssh has a directory sshd_config.d! The way I fixed it was settingPasswordAuthentication no in a conf file in that directory!

I thought sshd was used by RH and ubuntu used ssh (as in sudo systemctl restart ssh)!

pe flag

I would first check to see if you have an Include directory (or file) defined, such as:


There's a chance there is an include file that is overriding /etc/ssh/sshd_config

Next, see what systemctl is doing. Look at /etc/sysconfig/sshd and /etc/sysconfig/sshd-permitrootlogin and maybe adjust those, as needed. Those are the path/filenames on RHEL 8, I think it's the same for Ubuntu 22.04.

I would also check the ssh client. An ssh command-line option -o PreferredAuthentications=password might override the server preference. Check to see if something similar exists in your client's ~/.ssh/config file, or if using he server's client (to localhost), it may use /etc/ssh/ssh_config.

I sit in a Tesla and translated this thread with Ai:


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.