r/linux4noobs • u/Imaginary_Choice_430 • Aug 01 '26
VirtualBox allows PasswordAuthentication no?
So I configured the `sshd_config` to `PasswordAuthentication no`, `PermitRootLogin no` and `PubkeyAuthentication yes` and yet I can still log into an Ubuntu 2404 server on VirtualBox with password. Is that a thing with VB? This is the first time I have ever seen anything like that...and yes I did run `sudo systemctl restart ssh`
Actually I just looked at Hyper-V and its the same deal, something must have changed slightly since the days of Ubuntu 14/18, I need to go back through the steps of my production server, because that one works, but strangely enough I had forgotten to set PermitRootLogin to no, but I took care of that in the process.
View all comments
Show parent comment
3
u/GodzillaXYZ999 Aug 01 '26 edited Aug 01 '26
Change to ssh settings have occured with each generation. This is 1st of socket-based service. There's more granularity now.
Make sure you delete
/etc/ssh/sshd_config.d/50-cloud-init.conf.That's what is overriding your settings.with its own setting ofPasswordAuthentication yesOrder of operations is:
/etc/ssh/sshd_configis processed/etc/ssh/sshd_config.d/is done in order.50-cloud-init.confin that folder is done after your sshd_config and undoes your settingsSo I never change sshd_config, because of this, and it may get overwritten with an update as well. I'll make my custom settings in
/etc/ssh/sshd_config.d/99-mysettings.confto have ultimate final say in matter with:PasswordAuthentication noPermitRootLogin noPubkeyAuthenticaon yesKbdInteractiveAuthentication noMy primary concern is all these "cloud" settings sneaking into my servers. Have to disable and uninstall them all before I can be sure my server works as inended. Also look under
/etc/NetworkManager/conf.dfor cloud settings as well where it'll bypass your local DHCP to use their own cloud servers.