Let PAM to provision users on their first login

Nico Williams nico at cryptonector.com
Fri Nov 20 15:58:22 AEDT 2026


On Thu, Nov 19, 2026 at 10:33:40PM -0500, Demi Marie Obenour wrote:
> From the perspective of the authentication system, the user either
> exists or does not.  [...]

Time is a thing.  The user could not exist until after they jump through
some hoop.

>              [...].  However, I suspect NSS doesn't have the needed
> credentials to query if a user exists.  PAM, on the other hand, can
> include the user's credentials as part of its request, and can store
> the server's information for later use.

Sometimes.  PAM wouldn't have the user's credentials if they are not of
the username & password form (or whatever interactive prompt responses).

Think of GSS-API/Kerberos, publickey userauth, etc.  In some cases there
can be 'evidence of authentication' that a trusted third party might
accept for limited impersonation [e.g., to a directory service].  In
other cases there might a forwarded credential (e.g., Kerberos tickets)
that could be used to authenticate as the user to the directory (but
watch out! the user might be able to MITM that).  And in yet other cases
there may be nothing whatsoever to help the relying party authenticate
to the directory.

Must-authenticate-to-the-directory-as-the-user to find out the user's
details schemes are non-trivial.  And as to the name service switch and
PAM there's a serious last-mile problem: how do you furnish them with
the necessary credentials?  It's only easy when the credentials are of
the keyboard-interactive type, but that's rather dissatisfying because
people need non-interactive remote logons too.

Active Directory sort of manages this via stuffing user directory data
into their Kerberos session ticket, MACed with a KDC key that the
relying party has to turn around and ask a KDC to validate, and then
there's S4U which allows the Kerberos session ticket to be used as
evidence of the user having authenticated to the relying party so that a
KDC might allow the relying party to do limited impersonation of the
user.  It's non-trivial, and quite wedded to Kerberos, and Kerberos
kinda sucks if you've not noticed (I've only worked with or on Kerberos,
contributing to and/or maintaining more than one implementation, for
several decades).

PAM really needs pam_set_item() items for passing details of what
non-interactive authentication was used for the cases where sshd does
not call pam_authenticate().  And modules need a way to indicate that
they authorized those.  And sshd needs to check that they did.  Without
that -or a replacement for PAM that can do roughly that- then I'm afraid
that the the-relying-party-can't-look-up-the-user-without-their-help
model is just not workable on Unix-ish systems.

> Giving NSS the ability to query if any user exists would be a security
> risk (in case the server was compromised) and gain nothing other than
> making OpenSSH work.

How?  Is the user's UID a secret?  Is their GECOS field a secret?

Sure, one might want the directory to require user, not host,
authentication, AD-style, but we're far from having Unix-ish systems
architected for this even now, 26 years after Windows 2000 and Active
Directory.

Nico
-- 


More information about the openssh-unix-dev mailing list