Go to main content

man pages section 7: Standards, Environments, Macros, Character Sets, and Miscellany

Exit Print View

Updated: Wednesday, July 27, 2022



pam_authtok_get - authentication and password management module




The pam_authtok_get service module provides password prompting functionality to the PAM stack. It implements pam_sm_authenticate() and pam_sm_chauthtok(), providing functionality to both the Authentication Stack and the Password Management Stack.

Authentication Service

The implementation of pam_sm_authenticate(3PAM) prompts the user name if not set and then tries to get the authentication token from the pam handle. If the token is not set, it then prompts the user for a password and stores it in the PAM item PAM_AUTHTOK. This module is meant to be the first module on an authentication stack where users are to authenticate using a keyboard.

Password Management Service

Due to the nature of the PAM Password Management stack traversal mechanism, the pam_sm_chauthtok(3PAM) function is called twice. Once with the PAM_PRELIM_CHECK flag, and one with the PAM_UPDATE_AUTHTOK flag.

In the first (PRELIM) invocation, the implementation of pam_sm_chauthtok(3PAM) moves the contents of the PAM_AUTHTOK (current authentication token) to PAM_OLDAUTHTOK, and subsequentially prompts the user for a new password. This new password is stored in PAM_AUTHTOK.

If a previous module has set PAM_OLDAUTHTOK prior to the invocation of pam_authtok_get, this module turns into a NO-OP and immediately returns PAM_SUCCESS.

In the second (UPDATE) invocation, the user is prompted to re-enter password. The pam_sm_chauthtok implementation verifies this re-entered password with the password stored in PAM_AUTHTOK. If the passwords match, the module returns PAM_SUCCESS.

The following option can be passed to the module:


syslog(3C) debugging information at the LOG_DEBUG level


The authentication service returns the following error codes:


Successfully obtains authentication token


Fails to retrieve username, username is NULL or empty

The password management service returns the following error codes:


Successfully obtains authentication token


Authentication token manipulation error


See attributes(7) for descriptions of the following attributes:

Interface Stability
MT Level
MT-Safe with exceptions

See Also

syslog(3C), libpam(3LIB), pam(3PAM), pam_authenticate(3PAM), pam.conf(5), attributes(7), pam_authtok_check(7), pam_authtok_store(7), pam_dhkeys(7), pam_passwd_auth(7), pam_unix_account(7), pam_unix_auth(7), pam_unix_session(7)


The interfaces in libpam(3LIB) are MT-Safe only if each thread within the multi-threaded application uses its own PAM handle.