LinuxCommandLibrary

pam_keyinit

Initialize user keyring upon login

SYNOPSIS

To use pam_keyinit, it is configured in a PAM service file (e.g., /etc/pam.d/login or /etc/pam.d/system-auth) typically as a session module type:

session optional pam_keyinit.so [options]

The optional control flag ensures that the session can still be established even if keyring initialization fails, though this might compromise security features reliant on the keyring.

PARAMETERS

debug
    Enables verbose logging for debugging purposes. Information is typically sent to syslog.

force
    Forces the creation of a new session keyring, even if a session keyring already exists for the user. This ensures a fresh keyring for the session.

revoke
    Revokes any existing session keyrings belonging to the user at the start of the session. This is important for ensuring session isolation and preventing old keys from being reused or accessed.

keyring=name
    Specifies the name of the session keyring to be created. The default name is _ses.

alt_keyring=name
    Specifies an alternative name for the session keyring, primarily for backwards compatibility or specific integration scenarios.

root_keyring
    Causes the session keyring to be attached to the user's uid_keyring instead of the default process or thread keyring. This is useful for system services or specific use cases where the keyring needs to be persistent across all processes of a user ID.

DESCRIPTION

pam_keyinit is a PAM (Pluggable Authentication Modules) module designed to manage kernel keyrings for user sessions.
When a user logs in and a PAM session is initialized, pam_keyinit creates a unique session keyring for that user's session.
This keyring provides a secure, dedicated storage space within the kernel for cryptographic keys and other credentials that are specific to the user's current login session.
Applications that rely on kernel keyrings for security operations, such as disk encryption (e.g., LUKS) or secure communication, utilize this session keyring.
By establishing a distinct keyring for each session, pam_keyinit helps to isolate cryptographic material, enhancing security by ensuring that keys from one session do not leak or interfere with another. It is typically configured as a session type module in PAM configuration files (e.g., /etc/pam.d/system-auth or /etc/pam.d/login).

CAVEATS

Misconfiguration of pam_keyinit within the PAM stack can lead to unexpected behavior or security vulnerabilities. It is crucial to place it correctly as a session module.
If the revoke option is not used, previously created session keyrings might persist, potentially allowing access to old cryptographic material.
Understanding the lifecycle of kernel keyrings and their interaction with processes and threads is essential for effective use.

<B>KEYRING TYPES</B>

pam_keyinit primarily manages session keyrings, which are distinct from user keyrings (uid_keyring). A session keyring is tied to a specific login session and is typically destroyed when the session ends, while a user keyring is tied to the user ID and persists across different sessions (unless explicitly revoked).

<B>PAM MODULE TYPE</B>

It is essential that pam_keyinit is configured as a session module in PAM configuration files. This ensures that the keyring is correctly set up when a user's session begins and managed appropriately upon session termination.

HISTORY

The concept of kernel keyrings in Linux has evolved to provide a secure mechanism for managing cryptographic keys and authentication tokens within the kernel.
pam_keyinit was developed as a PAM module to seamlessly integrate this kernel keyring functionality into the user's login and session management process.
Its development reflects the ongoing effort to enhance security in Linux environments by providing better isolation and management of sensitive cryptographic material associated with user sessions.

SEE ALSO

pam(8), keyctl(1), keyrings(7), pam.conf(5)

Copied to clipboard