Table of Contents

Ubuntu - PAM - Configure PAM

The main configuration file for PAM is /etc/pam.conf and the /etc/pam.d/ directory contains the PAM configuration files for each PAM-aware application/services.

PAM will ignore the file if the directory exists.


Syntax of Main Configuration File

The syntax for the main configuration file is as follows.

service type control-flag module module-arguments 

where:

The file is made up of a list of rules written on a single line.

You can extend rules over multiple lines using the “\” escape character. For example:

aaa \
bbb

The format of each rule is a space separated collection of tokens (the first three are case-insensitive).

Comments are preceded with “#” marks and extend to the next end of line.


Syntax of PAM config files

The syntax of each file in /etc/pam.d/ is similar to that of the main file and is made up of lines of the following form:

type control-flag module module-arguments

This is a example of a rule definition (without module-arguments) found in the /etc/pam.d/sshd file, which disallows non-root logins when /etc/nologin exists:

account required pam_nologin.so

Understanding PAM Management Groups and Control-flags

PAM authentication tasks are separated into four independent management groups.

These groups manage different aspects of a typical user’s request for a restricted service.

A module is associated to one these management group types:

PAM loadable object files (the modules) are to be located in the following directory: /lib/security/ or /lib64/security depending on the architecture.

The supported control-flags are:

In addition to the above are the keywords, there are two other valid control flags: