From eeb6c4af39b5c58bdb08820cfe27a305cd8520d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 18 Nov 2026 22:21:47 +0000 Subject: [PATCH 1/9] servconf: Add PAMDeferUnknownUsers configuration option In the next commits it will allow first-login PAM provisioning to be controlled globally or by a Match rule on the requested login name. Document the first-login constraints so administrators can scope the feature to their PAM stack. --- servconf.c | 4 ++++ servconf.h | 2 ++ sshd_config.5 | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/servconf.c b/servconf.c index d40750a87..74e3b02d0 100644 --- a/servconf.c +++ b/servconf.c @@ -1211,6 +1211,9 @@ process_server_config_line_depth(ServerOptions *options, char *line, case sUsePAM: intptr = &options->use_pam; goto parse_flag; + case sPAMDeferUnknownUsers: + intptr = &options->pam_defer_unknown_users; + goto parse_flag; case sPAMServiceName: charptr = &options->pam_service_name; arg = argv_next(&ac, &av); @@ -4329,6 +4332,7 @@ dump_config(ServerOptions *o) /* integer arguments */ #ifdef USE_PAM dump_cfg_fmtint(sUsePAM, o->use_pam); + dump_cfg_fmtint(sPAMDeferUnknownUsers, o->pam_defer_unknown_users); dump_cfg_string(sPAMServiceName, o->pam_service_name); #endif dump_cfg_int(sLoginGraceTime, o->login_grace_time); diff --git a/servconf.h b/servconf.h index f31668549..39392687f 100644 --- a/servconf.h +++ b/servconf.h @@ -280,10 +280,12 @@ SSHCONF_ALIAS(KeepAlive, TCPKeepAlive, SSHCFG_GLOBAL) #ifdef USE_PAM #define SSHD_CONFIG_ENTRIES_PAM \ SSHCONF_INTFLAG(use_pam, UsePAM, SSHCFG_GLOBAL, 0, SSHCFG_COPY_NONE) \ +SSHCONF_INTFLAG(pam_defer_unknown_users, PAMDeferUnknownUsers, SSHCFG_ALL, 1, SSHCFG_COPY_MATCH) \ SSHCONF_STRING(pam_service_name, PAMServiceName, SSHCFG_ALL, SSHCFG_COPY_MATCH) #else #define SSHD_CONFIG_ENTRIES_PAM \ SSHCONF_UNSUPPORTED_INT(use_pam, UsePAM, SSHCFG_GLOBAL) \ +SSHCONF_UNSUPPORTED_INT(pam_defer_unknown_users, PAMDeferUnknownUsers, SSHCFG_ALL) \ SSHCONF_UNSUPPORTED_STRING(pam_service_name, PAMServiceName, SSHCFG_ALL) #endif diff --git a/sshd_config.5 b/sshd_config.5 index f98cbf888..a47330684 100644 --- a/sshd_config.5 +++ b/sshd_config.5 @@ -1380,6 +1380,7 @@ Available keywords are .Cm LogLevel , .Cm MaxAuthTries , .Cm MaxSessions , +.Cm PAMDeferUnknownUsers , .Cm PAMServiceName , .Cm PasswordAuthentication , .Cm PermitEmptyPasswords , @@ -1448,6 +1449,42 @@ and key exchange methods. The default is .Pa /etc/moduli . +.It Cm PAMDeferUnknownUsers +Controls whether +.Xr sshd 8 +lets PAM authenticate usernames that are not yet present in the system +user database. +This allows a PAM module or name service module that creates accounts on +their first login, such as one provided by a remote identity or directory +service, to provision the account as part of authentication. +.Pp +Only PAM keyboard-interactive authentication can provision an account. +The account must exist once that authentication, including PAM account +management, has completed. +.Pp +If the effective server configuration changes after the user is created, +the client must reconnect so authentication uses the new configuration +from the start. +Other methods, such as public key or host-based authentication, require the +user to exist, so for a user created on its first login they can only be +used after a PAM-based method, for example as a later method in +.Cm AuthenticationMethods . +.Pp +This option has no effect unless +.Cm UsePAM +is enabled. +.Pp +It may be used in a +.Cm Match +block, for example to only defer usernames within a particular domain: +.Bd -literal -offset indent +PAMDeferUnknownUsers no +Match User *@example.com + PAMDeferUnknownUsers yes +.Ed +.Pp +The default is +.Cm yes . .It Cm PAMServiceName Specifies the service name used for Pluggable Authentication Modules (PAM) authentication, authorisation and session controls when -- 2.53.0