Softpanorama
(slightly skeptical) Open Source Software Educational Society

May the source be with you, but remember the KISS principle ;-)

Softpanorama Search

Selected PAM Modules

News

Authentication and Accounts Security

PAM

Recommended Books

Recommended Links

Linux_PAM
SecurID PAM_Wheel pam_xauth pam_cracklib Humor Etc

Suse 10 comes with the complicated cornucopia of 64-bit PAM modules (located in /lib64/security):

-rwxr-xr-x 1 root root  13648 May  3  2007 pam_access.so
-rwxr-xr-x 1 root root  19440 May  3  2007 pam_chroot.so
-rwxr-xr-x 1 root root  12704 May  3  2007 pam_cracklib.so
-rwxr-xr-x 1 root root   7552 May  3  2007 pam_debug.so
-rwxr-xr-x 1 root root   4648 May  3  2007 pam_deny.so
-rwxr-xr-x 1 root root  15552 May  3  2007 pam_devperm.so
-rwxr-xr-x 1 root root   7368 May  3  2007 pam_echo.so
-rwxr-xr-x 1 root root  12064 May  3  2007 pam_env.so
-rwxr-xr-x 1 root root   8928 May  3  2007 pam_exec.so
drwxr-xr-x 2 root root   4096 Oct 17 14:33 pam_filter
-rwxr-xr-x 1 root root  13024 May  3  2007 pam_filter.so
-rwxr-xr-x 1 root root   6952 May  3  2007 pam_ftp.so
-rwxr-xr-x 1 root root  12792 May  3  2007 pam_group.so
-rwxr-xr-x 1 root root   8872 May  3  2007 pam_homecheck.so
-rwxr-xr-x 1 root root   9080 May  3  2007 pam_issue.so
-rwxr-xr-x 1 root root   9432 May  3  2007 pam_lastlog.so
-rwxr-xr-x 1 root root  13320 May  3  2007 pam_limits.so
-rwxr-xr-x 1 root root  11072 May  3  2007 pam_listfile.so
-rwxr-xr-x 1 root root   5976 May  3  2007 pam_localuser.so
-rwxr-xr-x 1 root root   6896 May  3  2007 pam_loginuid.so
-rwxr-xr-x 1 root root   9680 May  3  2007 pam_mail.so
-rwxr-xr-x 1 root root   8968 May  3  2007 pam_make.so
-rwxr-xr-x 1 root root  17952 May  3  2007 pam_mkhomedir.so
-rwxr-xr-x 1 root root   7504 May  3  2007 pam_mktemp.so
-rwxr-xr-x 1 root root   5688 May  3  2007 pam_motd.so
-rwxr-xr-x 1 root root  66824 May  3  2007 pam_ncp_auth.so
-rwxr-xr-x 1 root root   6872 May  3  2007 pam_nologin.so
-rwxr-xr-x 1 root root  16032 Apr 27  2007 pam_opensc.so
-rwxr-xr-x 1 root root  32600 Jun 16  2006 pam_opie.so
-rwxr-xr-x 1 root root  44088 May  3  2007 pam_passwdqc.so
-rwxr-xr-x 1 root root   5072 May  3  2007 pam_permit.so
-rwxr-xr-x 1 root root  32952 May  3  2007 pam_pwcheck.so
-rwxr-xr-x 1 root root   7984 Jun 16  2006 pam_resmgr.so
-rwxr-xr-x 1 root root   6072 May  3  2007 pam_rhosts.so
-rwxr-xr-x 1 root root  11352 May  3  2007 pam_rhosts_auth.so
-rwxr-xr-x 1 root root   4856 May  3  2007 pam_rootok.so
-rwxr-xr-x 1 root root  18056 May  4  2007 pam_rpasswd.so
-rwxr-xr-x 1 root root   7264 May  3  2007 pam_securetty.so
-rwxr-xr-x 1 root root   5976 May  3  2007 pam_shells.so
-rwxr-xr-x 1 root root  12528 May  3  2007 pam_stress.so
-rwxr-xr-x 1 root root  12928 May  3  2007 pam_succeed_if.so
-rwxr-xr-x 1 root root  11784 May  3  2007 pam_tally.so
-rwxr-xr-x 1 root root  11312 May  3  2007 pam_time.so
-rwxr-xr-x 1 root root   8448 May  3  2007 pam_umask.so
-rwxr-xr-x 2 root root  55872 May  3  2007 pam_unix.so
-rwxr-xr-x 2 root root  55872 May  3  2007 pam_unix2.so
-rwxr-xr-x 4 root root  42712 May  3  2007 pam_unix_acct.so
-rwxr-xr-x 4 root root  42712 May  3  2007 pam_unix_auth.so
-rwxr-xr-x 4 root root  42712 May  3  2007 pam_unix_passwd.so
-rwxr-xr-x 4 root root  42712 May  3  2007 pam_unix_session.so
-rwxr-xr-x 1 root root  11080 May  3  2007 pam_userdb.so
-rwxr-xr-x 1 root root   6192 May  3  2007 pam_userpass.so
-rwxr-xr-x 1 root root   5736 May  3  2007 pam_warn.so
-rwxr-xr-x 1 root root   7248 May  3  2007 pam_wheel.so
-rwxr-xr-x 1 root root  15496 May  3  2007 pam_xauth.so
			

A list from The PAM  reference guide for available modules:

pam_access - logdaemon style login access control
pam_cracklib - checks the password against dictionary words
pam_debug - debug the PAM stack
pam_deny - locking-out PAM module
pam_echo - print text messages
pam_env - set/unset environment variables
pam_exec - call an external command
pam_faildelay - change the delay on failure per-application
pam_filter - filter module
pam_ftp - module for anonymous access
pam_group - module to modify group access
pam_issue - add issue file to user prompt
pam_keyinit - display the keyinit file
pam_lastlog - display date of last login
pam_limits - limit resources
pam_listfile - deny or allow services based on an arbitrary file
pam_localuser - require users to be listed in /etc/passwd
pam_loginuid - record user's login uid to the process attribute
pam_mail - inform about available mail
pam_mkhomedir - create users home directory
pam_motd - display the motd file
pam_namespace - setup a private namespace
pam_nologin - is a PAM module that prevents users from logging into the system when /etc/nologin exists. The contents of the /etc/nologin file are displayed to the user. The pam_nologin module has no effect on the root user's ability to log in.
pam_permit - the promiscuous module
pam_pwcheck
6.25. pam_rhosts - grant access using .rhosts file
6.26. pam_rootok - gain only root access
6.27. pam_securetty is a PAM module that allows root logins only if the user is logging in on a "secure" tty, as defined by the listing in /etc/securetty. pam_securetty also checks to make sure that /etc/securetty is a plain file and not world writable. This module has no effect on non-root users and requires that the application fills in the PAM_TTY item correctly. For canonical usage, should be listed as a required authentication method before any sufficient authentication methods.
6.28. pam_selinux - set the default security context
6.29. pam_shells - check for valid login shell
6.30. pam_succeed_if - test account characteristics
6.31. pam_tally - login counter (tallying) module
6.32. pam_time - time controled access
6.33. pam_umask - set the file mode creation mask
6.34. pam_unix - traditional password authentication
6.35. pam_userdb - authenticate against a db database
6.36. pam_warn - logs all PAM items
6.37. pam_wheel - only permit root access to members of group wheel
6.38. pam_xauth - forward xauth keys between users

Common Pam modules:

Here is an example of user the ftpusers file to deny access to those listed in the file:

#
# deny ftp-access to users listed in the /etc/ftpusers file
#
ftp auth required pam_listfile.so \
onerr=succeed item=user sense=deny file=/etc/ftpusers
pam_mail -- [authentication (credential);session (open)]
This module provides the “you have new mail” service to the user. It can be plugged into any application that has credential hooks. It gives a single message indicating the newness of any mail it finds in the user's mail folder. This module also sets the Linux-PAM environment variable, MAIL, to the user's mail directory.

Less common PAM modules

Old News ;-)

freshmeat.net Project details for pam_require

pam_require is a simple Plugable Authentication Module (PAM) for Linux (and maybe other systems which use PAM). It is an account module that allows you to require a special group or user to access a service.

freshmeat.net Project details for pam_script

pam_script is a PAM that executes a script at the start and end of a session. Any PAM-aware application can use the module to perform arbitrary operations. It was originally written for cleaning up when a user logs out.

Author:
Izak Burger [contact developer]

Recipe 4.3, Creating Access Control Lists with PAM from Linux Security Cookbook
By Daniel J. Barrett,

Author's note: PAM (Pluggable Authentication Modules) is a flexible infrastructure for controlling authentication on Linux systems. In this recipe, taken from Chapter 4, "Authentication Techniques and Infrastructures," we show you how to restrict authentication to a given set of users by creating an access control list.

Problem

You would like to apply an access control list (ACL) to an existing service that does not explicitly support ACLs (e.g., telnetd, imapd, etc.).

Solution

Use the listfile PAM module.

First, make sure the server in question uses PAM for authentication, and find out which PAM service name it uses. This may be in the server documentation, or it may be clear from examining the server itself and perusing the contents of /etc/pam.d. For example, suppose you're dealing with the IMAP mail server. First notice that there is a file called /etc/pam.d/imap. Further, the result of:

# locate imapd
...
/usr/sbin/imapd

shows that the IMAP server is in /usr/sbin/imapd, and:

# ldd /usr/sbin/imapd
libpam.so.0 => /lib/libpam.so.0 (0x40027000)
...

shows that the server is dynamically linked against the PAM library (libpam.so), also suggesting that it uses PAM. In fact, the Red Hat 8.0 IMAP server uses PAM via that service name and control file ("imap").

Continuing with this example, create an ACL file for the IMAP service, let's say /etc/imapd.acl, and make sure it is not world-writable:

# chmod o-w /etc/imapd.acl

Edit this file, and place in it the usernames of those accounts authorized to use the IMAP server, one name per line. Then, add the following to /etc/pam.d/imap:

account required /lib/security/pam_listfile.so file=/etc/imapd.acl \
item=user sense=allow onerr=fail

With this configuration, only those users listed in the ACL file will be allowed access to the IMAP service. If the ACL file is missing, PAM will deny access for all accounts.

Discussion

The PAM "listfile" module is actually even more flexible than we've indicated. Entries in your ACL file can be not only usernames (item=user), but also:

The sense keyword determines how the ACL file is interpreted. sense=allow means that access will be allowed only if the configured item is in the file, and denied otherwise. sense=deny means the opposite: access will be denied only if the item is in the file, and allowed otherwise.

The onerr keyword indicates what to do if some unexpected error occurs during PAM processing of the listfile module - for instance, if the ACL file does not exist. The values are succeed and fail. fail is a more conservative option from a security standpoint, but can also lock you out of your system because of a configuration mistake!

Another keyword, apply=[user|@group], limits the restriction in question to apply only to particular users or groups. This is intended for use with the tty, rhost, and shell items. For example, using item=rhost and apply=@foo would restrict access to connections from hosts listed in the ACL file, and furthermore only to local accounts in the foo group.

To debug problems with PAM modules, look for PAM-specific error messages in /var/log/messages and /var/log/secure. (If you don't see the expected messages, check your system logger configuration. [Recipe 9.28])

Note that not all module parameters have defaults. Specifically, the file, item, and sense parameters must be supplied; if not, the module will fail with an error message like:

Dec  2 15:49:21 localhost login: PAM-listfile: Unknown sense or sense not specified

You generally do not need to restart servers using PAM: they usually re-initialize the PAM library for every authentication and reread your changed files. However, there might be exceptions.

There is no standard correspondence between a server's name and its associated PAM service. For instance, logins via Telnet are actually mediated by /bin/login, and thus use the login service. The SSH server sshd uses the same-named PAM service (sshd), whereas the IMAP server imapd uses the imap (with no "d") PAM service. And many services in turn depend on other services, notably system-auth.

See Also

See /usr/share/doc/pam-*/txts/README.pam_listfile for a list of parameters to tweak.

Recommended Links


In case of broken links please try to use Google search. If you find the page please notify us about new location
Google     

The Linux-PAM Administration and Developer Guides

6. A reference guide for available modules
6.1. pam_access - logdaemon style login access control
6.2. pam_cracklib - checks the password against dictionary words
6.3. pam_debug - debug the PAM stack
6.4. pam_deny - locking-out PAM module
6.5. pam_echo - print text messages
6.6. pam_env - set/unset environment variables
6.7. pam_exec - call an external command
6.8. pam_faildelay - change the delay on failure per-application
6.9. pam_filter - filter module
6.10. pam_ftp - module for anonymous access
6.11. pam_group - module to modify group access
6.12. pam_issue - add issue file to user prompt
6.13. pam_keyinit - display the keyinit file
6.14. pam_lastlog - display date of last login
6.15. pam_limits - limit resources
6.16. pam_listfile - deny or allow services based on an arbitrary file
6.17. pam_localuser - require users to be listed in /etc/passwd
6.18. pam_loginuid - record user's login uid to the process attribute
6.19. pam_mail - inform about available mail
6.20. pam_mkhomedir - create users home directory
6.21. pam_motd - display the motd file
6.22. pam_namespace - setup a private namespace
6.23. pam_nologin - prevent non-root users from login
6.24. pam_permit - the promiscuous module
6.25. pam_rhosts - grant access using .rhosts file
6.26. pam_rootok - gain only root access
6.27. pam_securetty - limit root login to special devices
6.28. pam_selinux - set the default security context
6.29. pam_shells - check for valid login shell
6.30. pam_succeed_if - test account characteristics
6.31. pam_tally - login counter (tallying) module
6.32. pam_time - time controled access
6.33. pam_umask - set the file mode creation mask
6.34. pam_unix - traditional password authentication
6.35. pam_userdb - authenticate against a db database
6.36. pam_warn - logs all PAM items
6.37. pam_wheel - only permit root access to members of group wheel
6.38. pam_xauth - forward xauth keys between users


Copyright © 1996-2009 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Site uses AdSense so you need to be aware of Google privacy policy. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

Disclaimer:

Last modified: August 17, 2009