Pluggable Authentication Modules (PAM)

From SaruWiki
Revision as of 12:28, 5 November 2008 by Saruman! (talk | contribs) (Created article structure)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Pluggable Authentication Modules for Linux (Linux-PAM) is a great way to fit your Linux server with authentication-related services. However, we found their use pretty difficult, due to some aspects of PAM not being as obvious as the tutorial and howto-writers apparently expect. Thus, we here try to explain ourselves (and you, dear reader) how PAM works.

PAM introduction

What is PAM

First the well-known basics. Free from the PAM admin guide:

Linux-PAM is a suite of shared libraries. Using these libraries, the local system administrator can specify how (PAM-aware) applications authenticate users. In other words, if an application or service is PAM-aware, then it is possible to switch between the authentication mechanism(s) it uses without (rewriting and) recompiling it. Indeed, one may entirely upgrade or reconfigure the local authentication system without touching the applications themselves.

Historically, an application that required a given user to be authenticated had to be compiled to use a specific authentication mechanism. For example, in the case of traditional UN*X systems, the identity of the user is verified by the user entering a correct password. This password, after being prefixed by a two character "salt", is encrypted (with crypt(3)). The user is then authenticated if this encrypted password is identical to the second field of the user's entry in the system password database (the /etc/passwd file). On such systems, most if not all forms of privileges are granted based on this single authentication scheme. Privilege comes in the form of a personal user-identifier (UID) and membership of various groups. Services and applications are available based on the personal and group identity of the user. Traditionally, group membership has been assigned based on entries in the /etc/group file.

It is the purpose of the Linux-PAM project to separate the development of privilege granting software from the development of secure and appropriate authentication schemes. This is accomplished by providing a library of functions that an application may use to request that a user be authenticated. This PAM library is configured locally with a system file, /etc/pam.conf (or a series of configuration files located in /etc/pam.d/) to authenticate a user request via the locally available authentication modules. The modules themselves will usually be located in the directory /lib/security or /lib64/security and take the form of dynamically loadable object files

Why use PAM

PAM Principles

Invoking PAM

PAM modules - in general

A line of PAM configuration code

PAM module types

module type auth

module type account

module type password

module type session

PAM control flags

A line of PAM configuration code - revisited

PAM on Debian

PAM modules in Debian 5.0 'Lenny'

PAM configuration files

Configuration example

Configuring PAM for LDAP