Let PAM to provision users on their first login
Nico Williams
nico at cryptonector.com
Sat Nov 21 13:45:58 AEDT 2026
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.
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.
> > It's unclear to me what you mean here. What is not-compatible?
>
> In all traditional unix systems, a uid is already assigned to (at least one)
> name entry.
User login and account creation could be racing.
> Furthermore in 99% of Linux systems today, the uid is already assigned
> in the same classic way.
>
> So what you are describing is a new behaviour. We are on the same page,
> right?
I (not OP) agree it's new behavior. I don't agree it's dangerous, much
less undesirable.
25 years ago I wrote a PAM that sent the user's username and password to
a service that validated them (using a hash in NIS) and then created any
missing Kerberos principal. That module combined with pam_krb5 allowed
us to begin a migration to Kerberos without having to ask users to
execute a manual and interactive enrollment process. It's... not the
same thing that OP is proposing here, but it's not altogether different
either. If OP has a compelling use-case (and mine from 2001 I would say
was compelling) then I don't see the problem.
> > > Outside of the sshd context, I think the Ubuntu design is extremely
> > > dangerous and in time there will be interesting consequences.
> >
> > What we did is mostly because the SSH behavior is not complying with
> > any other UNIX tool out there, as it requires user accounts to exist
> > ahead of time, while that's against any NSS design out there IMHO.
>
> 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.
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.
> > What we did in our NSS module is of course not great because it makes
> > way more complex something that should be just work, but the way it's
> > designed did not outline major issues so far. Hoping that will continue.
>
> Then we come to that you've made custom changes to NSS, which did not
> exist.. until recently, right?
NSS is pluggable. A plugin shouldn't count as 'custom changes to' the
pluggable thing.
> What you did in your NSS is very unlike tranditional Unix, and I believe
> this friction you encounter here is only the beginning of a long story.
I think it's very unlike OpenBSD. I don't think it's very unlike any
other Unix-ish OSes.
> I do not believe you'll be able to account for all the consequences in
> applications ahead of time.
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.
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.
I.e., I don't think OP's proposal will work in many/most interesting
cases, so 'why bother?' is a reasonable reason to reject, but the
traditional Unix response is not really compelling since a) Unix systems
have evolved plenty since 1978, so why not evolve more?, and b) there's
the risk of getting into a no true scotsman debate, making the
traditional Unix argument either moot or at least partly false. I.e.,
the traditional Unix argument is not very strong. IMO.
Nico
--
More information about the openssh-unix-dev
mailing list