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