|
Softpanorama |
May the source be with you, but remember the KISS principle ;-)
|
| Authentication and Accounts Security | Recommended Books | Linux_PAM | |||
| SecurID | PAM_Wheel | 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:
Common Pam modules:
pam_wheel -- Only permit root access to members
of the wheel (gid=0) group. This is similar to theFreeBSD style wheel access,
so that you can't su to root unless you are in the wheel group.
pam_env.so -- Sets environment variables
for PAM using the settings in /etc/security/pam_env.conf.
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
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.
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]
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
listfilePAM 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/imapdshows 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.aclEdit 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=failWith 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:
- Terminal lines (
item=tty)- Remote host (
item=rhost)- Remote user (
item=ruser)- Group membership (
item=group)- Login shell (
item=shell)The
sensekeyword determines how the ACL file is interpreted.sense=allowmeans that access will be allowed only if the configureditemis in the file, and denied otherwise.sense=denymeans the opposite: access will be denied only if the item is in the file, and allowed otherwise.The
onerrkeyword 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 aresucceedandfail.failis 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 thetty,rhost, andshellitems. For example, usingitem=rhostandapply=@foowould restrict access to connections from hosts listed in the ACL file, and furthermore only to local accounts in thefoogroup.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, andsenseparameters 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 specifiedYou 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
loginservice. The SSH serversshduses the same-named PAM service (sshd), whereas the IMAP serverimapduses theimap(with no "d") PAM service. And many services in turn depend on other services, notablysystem-auth.See Also
See /usr/share/doc/pam-*/txts/README.pam_listfile for a list of parameters to tweak.
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-2008 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). Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
Standard disclaimer: The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.
Last modified: June 02, 2008