I was setting up an ubuntu server and, like 99% of all people, one of the first things I do is to disable password authentication in favor of keys.
On other distros and in other times this is done by merely editing /etc/ssh/sshd_conf and making sure that...
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePam no
As you may already know, just doing that no longer works because near the beginning, the sshd_conf file includes ANOTHER conf file with...
Include /etc/ssh/sshd_config.d/*.conf
The file included is something named 50-cloud-init.conf whose sole contents upon installation happens to be...
PasswordAuthentication yes
Conf files that are included from sshd_conf.d override the original sshd_conf so if one were to just change sshd_conf, 50-cloud-init.conf would then flip back the password authentication setting. Changing it to 'no' will finally disable password logins.
I've done this twice and have forgotten about it each time. I will remember now, but it bugs me because I can't fathom what the rationale is for this stuff.
Searching around, so far, has yielded not much in terms of "why". Mostly folks are just happy to overcome this little obstacle and move on. I am glad it's resolvable but I got questions:
The name of this extra conf file suggests it's something to do with cloud-based installations. But what cloud? I installed this on a physical machine. Presumably
cloud-inithas created this for me, but why? I am not running in a cloud environment. Also, what's "50"? 50 what? Moreover, the ONLY line that it has enables password auth. In cloud installations doesn't everyone always use keys anyway?I see that it's possible to just remove cloud-init for non-cloud installs. Are there any caveats to doing that? It seems weird that this would be installed and running by default EVEN on non-cloud installations. There must be a reason for it, right?