SSH password auth keeps being set to "no" automatically

I’m attempting to use the AlmaLinux 9 cloud img and i’m finding that my config in the sshd_config file keeps being reset. “passwordauthentication” is set to no when I had set it to yes. It results in the following message when trying to connect by SSH.

No supported authentication methods available (server sent: publickey,gssapi-keyex,gssapi-with-mic)

Any advice would be appreciated.

Do not edit that file. The first non-comment in it should be:

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

Do look what /etc/ssh/sshd_config.d/*.conf files you do have.

You want to add a *.conffile that is lexicographically before any of those
and has the settings that you want. SSH does use first occurrences.

Plan A:
Its a cloud image, so it probably has cloud_init and the hypervisor that spawns the instance may offer a way to supply cloud_init customization script. (OpenStack does.)

If could_init sets the sshd config, then you might be able to change that bit of could_init config and never have to touch sshd config directly.

I do think it might be caused by the default cloud_init conf based on the info i’m finding online, as you mentioned too. I’m about to start testing today to see if that is the issue. Appreciate the insight.

aren’t you supposed to disable the cloud-init service after first boot or it’ll keep running on subsequent reboots…?

i’d think sudo systemctl disable cloud-init or mask even should work although there’s some horrible alternatives in the official docs

looks like its set in /etc/ssh/sshd_config not an include file:

I was able to fix this by editing the cloud init file at /etc/cloud/cloud.cfg. The first two options needed to be set to my needs and was the culprit overwriting my changes to the ssh config file.

I do use this in cloud environment so cloud init is needed to configure the user/network.

Ty for the assists