pam_ssh_auth_info(8)
pam_ssh_auth_info(8) π
okay bestie, gather round, because today we're talking about pam_ssh_auth_info β yes, that's the whole name, it lives in section 8 of the system manager's manual, and it's literally the module that tests SSH authentication information. That's the NAME, that's the whole job description, and it's serving. β¨
πΈ SYNOPSIS πΈ
pam_ssh_auth_info.so [flag...] [pattern[=pattern]...]
like... it takes flags, it takes patterns, it's flexible, it's giving range. π
π¦ DESCRIPTION π¦
so the pam_ssh_auth_info.so PAM module is designed to either succeed or fail authentication based on SSH authentication information β and that info is a whole list of successfully completed authentication methods plus public credentials (e.g. keys) that were used to authenticate the user. one very real use case? picking whether to load other modules based on this test. slay.
normally you hand the module zero or more patterns as module arguments, and authentication succeeds if the SSH authentication information matches all of the patterns (or any of them, or none of them β depends on which options you picked, bestie, it's giving choose-your-own-adventure). and here's the plot twist: if there are no previous successfully completed authentication methods, then SSH authentication information is not available β it's missing β and authentication will neither succeed nor fail (the module returns PAM_IGNORE). iconic neutrality honestly. π«Ά
β¨ OPTIONS β¨
these flags are supported, no cap:
all_ofβ all of the patterns must match. if zero patterns are given as module arguments, authentication will succeed if SSH authentication information is available. this is the default, it's the main character. πany_ofβ at least one of the patterns must match. if zero patterns are given as module arguments, authentication will fail if SSH authentication information is available. (yes, zero patterns = fail here, that's not a typo, that's the vibe.)debugβ log debugging messages to syslog. πdisable=service[:service[...]]β disable pattern matching for the services listed in that colon-separated service list.enable=service[:service[...]]β enable pattern matching only for the services listed in that colon-separated service list.none_ofβ none of the patterns may match. if zero patterns are given as module arguments, authentication will succeed if SSH authentication information is available.quietβ do not log failure or success messages to syslog. π€«quiet_failβ do not log failure messages to syslog.quiet_successβ do not log success messages to syslog.recursion_limit=limitβ change the recursion limit. this affects extended patterns and*wildcard patterns.
π PATTERNS π
any character byte that shows up in a pattern β other than the extended patterns and the special pattern characters described below β matches itself. simple, honest, humble.
the special pattern characters have these meanings, bestie:
*β matches any number of (including zero) word character bytes but not a word separator (space).=β matches an equal-sign (=) or a word separator (space).
this enables more natural looking patterns and allows patterns to be written without spaces, avoiding the need for square bracket quoting in PAM configuration files. it's giving convenience. π
?β matches any word character byte but not a word separator (space).[β a pair of brackets introduces a character byte class. a character byte class ([...]) matches any word character byte in the class. a complemented character byte class ([!...]) matches any word character byte not in the class. neither one matches a word separator (space). a class may contain character bytes ([abcde]) and character byte ranges ([a-e]).\β preserves the literal meaning of the following character byte.
the extended patterns have these meanings:
?(pattern|pattern|...)β matches zero or one occurrence of the given patterns. does not match a word separator (space).*(pattern|pattern|...)β matches zero or more occurrences of the given patterns. does not match a word separator (space).+(pattern|pattern|...)β matches one or more occurrences of the given patterns. does not match a word separator (space).@(pattern|pattern|...)β matches one of the given patterns. does not match a word separator (space).!(pattern|pattern|...)β matches anything except one occurrence of the given patterns. does not match a word separator (space).
SSH authentication information consists of lines having a format like
method[/submethod] [key-type key-data] [info-word]...
SSH authentication information matches a pattern if on any such line all the words or the initial words match the pattern. fr fr.
π MODULE SERVICES PROVIDED π
all module types are provided β account, auth, password and session. that said, the auth type is still undoubtedly the most useful one. like, obviously. π
π RETURN VALUES π
PAM_AUTH_ERRβ pattern requirements are not met. SSH authentication information does not match all of or any of the patterns (see theall_ofand theany_ofoptions) or matches some of the patterns (see thenone_ofoption). πPAM_IGNOREβ the pattern matching is disabled for the service (see thedisableoption) or not enabled for the service (see theenableoption) or SSH authentication information is missing.PAM_SUCCESSβ pattern requirements are met. SSH authentication information matches all of or any of the patterns (see theall_ofand theany_ofoptions) or matches none of the patterns (see thenone_ofoption). ate. π₯
β EXAMPLES β
example 1: always load an OATH module rule (to request and check a one-time password) but load a password module rule (to request and check the user password) only if there are no previous successfully completed authentications (in which case SSH authentication information is missing):
auth requisite oath-module.so option...
auth [success=1 \
default=ignore] pam_ssh_auth_info.so
auth required password-module.so try_first_pass option...
example 2: load an OATH module rule (to request and check a one-time password) only if there are no previous successfully completed FIDO authenticator algorithm based public key authentications (in which case SSH authentication information either is missing or does not match the pattern) but always load a password module rule (to request and check the user password):
auth [success=1 \
ignore=ignore \
auth_err=ignore \
default=die] pam_ssh_auth_info.so quiet \
publickey=*sk-*@openssh.com
auth requisite oath-module.so option...
auth required password-module.so try_first_pass option...
example 3: require that there is at least one previous successfully completed FIDO authenticator algorithm based public key authentication (in which case the key type contains βsk-β and ends with β@openssh.comβ). if multiple public key authentications are required, only one of them is required to be a FIDO authenticator algorithm based one.
auth requisite pam_ssh_auth_info.so quiet \
publickey=*sk-*@openssh.com
example 4: require that there is at least one previous successfully completed FIDO authenticator algorithm based public key authentication (in which case the key type contains βsk-β and ends with β@openssh.comβ) and at least one previous successfully completed non-FIDO public key authentication (in which case the key type does not contain βsk-β or does not end with β@openssh.comβ).
auth requisite pam_ssh_auth_info.so quiet \
publickey=*sk-*@openssh.com \
publickey=!(*sk-*@openssh.com)
π§ ENVIRONMENT π§
SSH_AUTH_INFO_0β SSH authentication information consisting of a list of successfully completed authentication methods and public credentials (e.g. keys) used to authenticate the user. this environment variable is visible to PAM modules but not to user sessions, and it is provided by OpenSSH server since version7.8p1.SSH_USER_AUTHβ a location of a file containing SSH authentication information consisting of a list of successfully completed authentication methods and public credentials (e.g. keys) used to authenticate the user. this environment variable is visible to user sessions but not to PAM modules, and it is provided by OpenSSH server since version7.8p1if theExposeAuthInfoserver option is enabled. this may be a useful source for creating proper patterns. lowkey a cheat code for pattern-making. π
π«Ά NOTES π«Ά
in order to make this module useful, the following sshd_config(5) options should be set (either explicitly or via defaults):
AuthenticationMethodsβ should contain comma-separated lists of authentication method names withkeyboard-interactive,keyboard-interactive:pamorpasswordas the last list items so that there are successfully completed authentication methods and public credentials (e.g. keys) during the PAM authentication. for example
AuthenticationMethods publickey,keyboard-interactive
for mandatory public key authentication and mandatory PAM authentication using keyboard-interactive challenge-response authentication or
AuthenticationMethods publickey,keyboard-interactive keyboard-interactive
for optional public key authentication and mandatory PAM authentication using keyboard-interactive challenge-response authentication.
ChallengeResponseAuthentication,KbdInteractiveAuthentication,PasswordAuthentication, etc. β the relevant ones should be set toyes.UsePAMβ should be set toyes.
ngl bestie, if you skip these, the module is just gonna sit there looking cute and doing nothing. set them up. π
π SEE ALSO π
pam(7),sshd_config(5)- Home Page for
pam_ssh_auth_info
π AUTHOR π
Eero HΓ€kkinen <Eero+pam-ssh-auth-info@HΓ€kkinen.fi>
π COPYRIGHT π
Copyright Β© 2021 - 2022 Eero HΓ€kkinen <Eero+pam-ssh-auth-info@HΓ€kkinen.fi>
This manual page is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
and that's the whole page, bestie!! this one comes to you from the System Manager's Manual, dated 2022-01-16, and honestly? iconic of it. go forth and pattern-match. periodt. π β¨π¦
π¦ where this page comes from
- epel 9: pam-ssh-auth-info 1.8.20230906-2.el9 Β· GPL-3.0-or-later AND LGPL-3.0-or-later
- fedora 43: pam-ssh-auth-info 1.8.20230906-7.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later
- fedora 44: pam-ssh-auth-info 1.8.20230906-8.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later
- Copyright Β© 2021 - 2023 Eero HΓ€kkinen <Eero+pam-ssh-auth-info@HΓ€kkinen.fi>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms