Let PAM to provision users on their first login

Nico Williams nico at cryptonector.com
Fri Nov 20 10:22:02 AEDT 2026


On Thu, Nov 19, 2026 at 10:10:20PM +0000, Marco Trevisan wrote:
> On 19 nov 2026 at 15:43, Nico Williams wrote:
> > But PAM a) SUX, b) does need more ways to tell the modules how the user
> > was authenticated when the 'how' is "not with pam_authenticate()" (i.e.,
> > not keyboard-interactive, not password) so that PAM could make better
> > authorization decisions.
> 
> We can all agree on a), but again it's the only standard we have so far.

(FYI I was paraphrasing a then OS/Net (Solaris core) gatekeeper at Sun
who said in a meeting that "the way to spell PAM is S-U-X" as he wrote
that on a whiteboard.  A great moment.  I wish it was on video.  It was
a long time ago.)

> We do want to work on something better that systemd can provide, but again
> that will be even less supported and definitely very linux/systemd bound.
> 
> I'm unsure I got your b) point fully.

We need pam_set_item() items for:

 - bare public keys for authorized_keys type authz
 - certificates
 - GSS-API names (exported composite name tokens)
 - JWTs
 - etc.

where the app (sshd in this case) ran the cryptographic authentication
protocol and some PAM does the authz work.  But that's not enough: the
app has to know which items were used, otherwise it's too easy to
misconfigure a system to let anyone in (see point (a)).  I would not
trust PAM to do authorization today, no way.  And though I disagree with
the OpenSSH maintainers about the wisdom of deferring the getpwnam()
call, in the context of PAM I can't blame them too much -- PAM really
sux.

Ideally PAM should be replaced with something better, but failing that I
would add `PAM_{...}` items for the above and also `PAM_ACK_{...}` items
that modules must set to let the app know that the corresponding
`PAM_{...}` items were actually considered and used to make a _positive_
decision.  But coordinating this is a real pain.  Though on the plus
side LinuxPAM is liberally-licensed, so maybe not that much
coordination, but still, adding things to it will be a pain in some way
or another (think of #ifdefs in PAM-using apps).

Nico
-- 


More information about the openssh-unix-dev mailing list