Let PAM to provision users on their first login
Marco Trevisan
marco at ubuntu.com
Tue Nov 24 05:13:55 AEDT 2026
On 20 nov 2026 at 20:45, Nico Williams wrote:
> On Thu, Nov 19, 2026 at 03:00:36PM -0600, Theo de Raadt wrote:
>> Marco Trevisan <marco at ubuntu.com> wrote:
>>>> I agree. The proposal is no longer compatible with Unix / POSIX
>>>> properties, and sshd the very last place this kind of thing should
>>>> occur.
>
> I don't agree with that. There's no backwards-incompatibility in
> allowing a user account to appear as part of a login attempt that then
> continues to exist thereafter but did not exist before.
Indeed, otherwise stuff such as `pam_mkhomedir` whouldn't had a reason
to exist, as they were non-UNIX indeed.
And sure, PAM may not be something all the UNIX systems rely on, but
while
it's far from being perfect, it's what most of the unix-based systems
rely
on for many years.
> A use-case would be a PAM that lets a user sign-up at the login, much
> like how many web sites do it. Instead of:
>
> Login: ...
> Password: ...
>
> one might get:
>
> Login (or empty to sign up):
> Email address: joe at six.pack
> Enter confirmation code: 012345
> Enter new password: ************
> Enter new password again: ************
> Welcome!
>
> What might be incompatible is that an account appears not to exist
> unless the user logs in, because then `ls -l` will not resolve UIDs of
> local files they use. But one could quibble about that.
Well that's exactly the flow we already support now as per
https://ubuntu.com/docs/authd/stable-docs/howto/login-ssh/
The screenshot does not show the local password creation, but that's
the follow-up request.
And indeed the user and its UID is associated once the log-in is
completed, and the nss module ensures that's the user is resolved
by that point.
> User login and account creation could be racing.
Sure, but there's already a locking mechanism for that, based on
lckpwdf, that all the NSS-based mechanisms should follow, so that's
not an issue either.
> I (not OP) agree it's new behavior. I don't agree it's dangerous,
> much
> less undesirable.
I do agree is a new behavior for SSHd, it's not for other login tools as
(as said), `login` implementation is already supporting this behavior
forever since it's meant to work for users that are not known until they
have released their credentials.
And the fact of being new is due to the fact that so far not many
identity
providers supported OAUTH2 based authentication systems, that just rely
on
the fact that the user is released by a 3rd party server you cannot
really
inspect for user existence without credentials.
>> Most unix systems do not use NSS, let alone this extension you are
>> talking about.
>>
>> NSS is not in POSIX. NSS is not a part of Unix. It exists in a
>> fraction of the variety of system that OpenSSH runs on.
>
> I assume NSS here == name service switch.
Sure thing
> Solaris and Illumos derivatives have been using a name service switch
> for 30+ years. Linux certainly uses one (well, glibc). NetBSD,
> FreeBSD, and DagonFly use a name service switch. OpenBSD does not.
>
> I'm not sure how small a fraction you had in mind, but it might be a
> very large fraction.
That's my feeling too, but I understand that being sshd an OpenBSD
project
it may indeed not be the upstream focus.
But here we don't really want to derail from what is the upstream main
interest, but rather support both scenarios in a safe way.
> I don't see how delaying the call to getpwnam() till after
> pam_authenticate() or pam_acct_mgmt() is a serious problem. Having
> resolved the username to a UID and other metadata is so critical that
> clearly sshd would not forget to call getpwname(), and you wouldn't
> allow it to either.
Yeah, I think this is not unsafe at all, if you trust your PAM stack,
of course.
Indeed our way to deal with it (via NSS creating temporary UIDs that
then needs to be associated with the actually PAM-authenticated
user) it's way more complex to handle, since we've to do the work
off-process.
And while this works, it requires way more checks than necessary if
sshd would just do the checks later in the process.
> What is a serious problem is that none of this will work for anything
> other than password or keyboard-interactive userauth because the point
> is that either the PAM/NSS modules will need user credentials, or an
> interactive user account sign-up is involved, and the former can't
> work
> with non-interactive userauth due to limitations of those userauth
> methods and/or limitations of PAM, and the latter is strictly
> interactive and requires keyboard-interactive userauth.
Yeah, as we need to have PAM in the loop here (in the lack of something
better), indeed this would be working with keyboard-interactive setup
(or password, but that's again only if goes through PAM).
More information about the openssh-unix-dev
mailing list