Let PAM to provision users on their first login
Marco Trevisan
marco at ubuntu.com
Fri Nov 20 07:39:39 AEDT 2026
Hi,
On 19 nov 2026 at 14:01, Damien Miller wrote:
>> This series adds a PAMDeferUnknownUsers option (defaulting to yes).
>> When it applies and the NSS lookup is a clear not-found, sshd
>> lets the PAM keyboard-interactive conversation run, then
>> re-checks the user in the monitor before the method is counted:
>
> I don't love this because it fairly significantly complicates
> some of the most critical code in OpenSSH.
>
> If this were just reversing the order in which we call getpwnam() and
> pam_start() then it wouldn't be so bad, but requiring sshd proceed
> with
> an invalid account right up to the point of authentication success is
> pretty scary.
Do you think just reversing the order is just possible?
As of course we do have to go through authentication.
It's also what any other PAM based authentication system does, it
never tries to ensure that an account exists as it just may be not
defined
yet.
And this is something that even matters most when it comes to use
accounts
based on systemd-userdb and it will matter even more in future when an
authentication method may just provide the user once we've passed
through
authentication systems (see the work we're discussing at
https://github.com/systemd/systemd/pull/39855).
Regarding the "proceed with an invalid account up to authentication"
point,
however, that is already what sshd does.
For an unknown user it runs the whole PAM conversation anyway, with
fakepw()
and a fake password, so that timing and replies don't reveal which
accounts
exist.
What the series adds is passing the real credentials and checking the
account
again after success.
I do understand that makes things a bit more complex, but the decision
of
ignoring accounts that are not exposed by NSS at the time of the initial
lookup is something that is not something that matches with the idea of
NSS.
> The "monitor: Receive PAM account requests only after authentication"
> bit is good though and mirrors a hardening that I've wanted to do for
> a while.
Ok, let me know if there's some work you want me to driver based on
that or
if that's good for landing.
More information about the openssh-unix-dev
mailing list