25

I configured login by SSH key which is working but I can still login by password, which I don't want.

I used sudo nano /etc/ssh/sshd_config to make the following changes:

PasswordAuthentication no
PubkeyAuthentication yes

I disabled the root login because my user can log in.

It should refuse login with password but it still allows it.

My version of ssh is OpenSSH_8.9p1 Ubuntu-3, OpenSSL 3.0.2 15 Mar 2022 on Ubuntu 22.04.

How do I disable the ability to login with password over SSH?

Nmath
  • 12,664

1 Answers1

54

I realized that a file /etc/ssh/sshd_config.d/50-cloud-init.conf was being referenced in my /etc/ssh/sshd_config, via the following line:

Include /etc/ssh/sshd_config.d/*.conf

this 50-cloud-init.conf file contained the line:

PasswordAuthentication yes

I changed the line to:

#PasswordAuthentication yes

and i restarted the ssh.

Now it is working, I can access only with the ssh key.

alelom
  • 105