Score:0

Chages to sshd_config not disable password only login

is flag

I have Ubuntu 22.04.2 LTS installed as a virtual machine (Windows Hyper-V). I am making the following changes to /etc/ssh/sshd_config

PermitRootLogin prohibit-password
PubkeyAuthentication yes
PubkeyAcceptedKeyTypes=+ssh-rsa
PasswordAuthentication no
ChallengeResponseAuthentication no

After the changes are made sudo sshd -t throws no errors.

I have tried many options (list below) to restart/reload sshd service:

sudo service sshd restart
sudo systemctl restart sshd.service
sudo service sshd reload
sudo systemctl reload sshd.service
sudo kill -SIGHUP $(pgrep -f "sshd -D")

but regardless of the command (or even if I execute all of them) I am still able to log into virtual machine providing password only. Even after reebot I can log into virtual machine.

For clarification the virtual machine is running on ip 172.30.42.222 while WSL from which I am login in runs on 172.30.32.1

ec flag
**Welcome to the Ask Ubuntu community.** This [AskUbuntu thread](https://askubuntu.com/q/922328/32664) may help resolve your issue.
Score:1
is flag

It seems that the problem was solved. I have commented one line in

/etc/ssh/sshd_config.d/50-cloud-init.conf

and of course the line was

PasswordAuthentication yes

First uncommented line in /etc/ssh/sshd_config is Include /etc/ssh/sshd_config.d/*.conf which indicates that the file /etc/ssh/sshd_config.d/50-cloud-init.conf is included into sshd_config. However the line PasswordAuthentication no is sshd_config comes after the Include... line which suggest that the latter line should be valid.

Can anyone comment on that issue?

hr flag
From `man sshd_config`: *"For each keyword, the first obtained value will be used."*
Jan Pips avatar
is flag
Thanks for clarification.
Score:0
tg flag

I solved using this answer https://askubuntu.com/a/1440509/1713168

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 no

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

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.