Score:5

Unable to disable password authentication over SSH

ss flag

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 avatar
ng flag
did you restart the ssh service? `sudo service ssh restart`
ar flag
You may also need `ChallengeResponseAuthentication no` in `/etc/ssh/sshd_config`. To restart sshd: `sudo systemctl restart ssh`.
Mário Alves avatar
ss flag
doesn't work. i inserted ChallengeResponseAuthentication no in /etc/ssh/sshd_config and restared the shh and down's work. like i sair in new answer. yes i did sudo service ssh restart but is in the same... my vps in on Contabo. I tried this on another vps on vultr, and it works... it disables the login with password. its possible the contabo has something configured?
ar flag
The comments are our channel to ask you for clarifications. Please edit the question. Do not ask a new question in the comments or in the answer. Questions about any specific VPS like Contabo is off topic here. You have to ask them.
Mário Alves avatar
ss flag
sorry. i already deleted the answer. i asked them, but they dont care and they take a long time to answer. but i think that i haved this well configured.
Score:17
ss flag

I already resolved this issue. Inside the directory /etc/ssh/sshd_config.d/ there is only one .conf file (50-cloud-init.conf), but inside it contains the line: PasswordAuthentication yes

I changed the line to #PasswordAuthentication yes

and i restarted the ssh. Now is working. I can only access with the ssh key.

Thanks.

Pythagoras of Samos avatar
br flag
I can't believe I wasted 3 hours over this looking for solutions. Thank you.
Fábio Junio Alves Sousa avatar
de flag
Many thanks for that, I was having the same issue and that also worked for me!
JavaKungFu avatar
pl flag
wow that's super annoying - thanks though you saved me a bunch of time!
Rörd avatar
cn flag
Why would they ship it with an extra config file that overrides such a central setting from the base config file?
I sit in a Tesla and translated this thread with Ai:

mangohost

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.