Table of Contents
When a person (or a program) requests access to the system, authentication confirms the identity to be a trusted one.
Configuration errors of PAM may lock you out of your own system. You must have a rescue CD handy or setup an alternative boot partition. To recover, boot the system with them and correct things from there.
Normal Unix authentication is provided by the
pam_unix(8) module under the PAM (Pluggable Authentication Modules). Its 3 important configuration files, with "
:" separated entries, are:
Table 4.1. 3 important configuration files for
||The (sanitized) user account information.|
||The secure user account information.|
||The group information.|
... user1:x:1000:1000:User1 Name,,,:/home/user1:/bin/bash user2:x:1001:1001:User2 Name,,,:/home/user2:/bin/bash ...
As explained in
passwd(5), each "
:" separated entry of this file means:
The second entry of "
/etc/passwd" was used for the encrypted password entry. After the introduction of "
/etc/shadow", this entry is used for the password specification entry.
Table 4.2. The second entry content of "
the encrypted password is in "
|*||no login for this account|
|!||no login for this account|
... user1:$1$Xop0FYH9$IfxyQwBe9b8tiyIkt2P4F/:13262:0:99999:7::: user2:$1$vXGZLVbS$ElyErNf/agUDsm1DehJMS/:13261:0:99999:7::: ...
As explained in
shadow(5), each "
:" separated entry of this file means:
$1$" indicates use of the MD5 encryption. The "*" indicates no login.
... group1:x:20:user1,user2 ...
As explained in
shadow(5), each "
:" separated entry of this file means:
/etc/gshadow" provides the similar function as "
/etc/shadow" for "
/etc/group" but is not really used.
The actual group membership of a user may be dynamically added if "
Here are few notable commands to manage account information:
Table 4.3. List of commands to manage account information.
browse account information of "
browse shadowed account information of "
browse group information of "
||manage password for the account|
||set one-time password for the account activation|
||manage password aging information|
You may need to have the root privilege for some functions to work. See
crypt(3) for the password and data encryption.
On the system set up with PAM and NSS as the Debian alioth machine, the content of local "
When creating an account during your system installation or with the
passwd(1) command, you should choose a good password which consists of 6 to 8 characters including one or more characters from each of the following sets according to
Do not chose guessable words for the password.
There are independent tools to generate encrypted password with salt:
Table 4.4. List of tools to generate password.
Modern Unix-like systems such as the Debian system provide PAM (Pluggable Authentication Modules) and NSS (Name Service Switch) mechanism to the local system administrator to configure his system. The role of these can be summarizes as:
These PAM and NSS systems need to be configured consistently.
The notable packages of PAM and NSS systems are:
Table 4.5. List of notable PAM and NSS systems.
||V:81, I:99||972||Pluggable Authentication Modules (basic service)|
||V:1.9, I:4||404||Pluggable Authentication Module allowing LDAP interfaces|
||V:0.9, I:1.8||132||Pluggable Authentication Module to enable cracklib support|
||I:0.8||1156||Pluggable Authentication Modules (documentation in html and text)|
||V:95, I:99||11296||GNU C Library: Shared libraries which also provides "Name Service Switch" service|
||I:4||1952||GNU C Library: Manpages|
||I:1.5||12020||GNU C Library: Reference manual in info, pdf and html format (non-free)|
||I:54||144||NSS module for Multicast DNS name resolution|
||I:4||312||NSS module for using LDAP as a naming service|
NSS module for using LDAP as a naming service (new folk of
libpam-docis essential for learning PAM configuration.
glibc-doc-referenceis essential for learning NSS configuration.
You can see more extensive and current list by "
PAM is the most basic way to initialize environment variables for each program with the system wide default value.
Here are few notable configuration files accessed by the PAM:
Table 4.6. List of configuration files accessed by the PAM.
set up PAM configuration for the "
set up NSS configuration with the entry for each service. See
limit the user login by the
limit the tty for the root access by the
set access limit by the
set group based restraint by the
set environment variables by the
set additional environment variables by the
set locale by
set resource restraint (ulimit, core, …) by the
set time restraint by the
The limitation of the password selection is implemented by the PAM modules,
pam_cracklib(8). They can be configured by their arguments.
PAM modules use suffix "
The modern centralized system management can be deployed using the centralized Lightweight Directory Access Protocol (LDAP) server to administer many Unix-like and non-Unix-like systems on the network. The open source implementation of the Lightweight Directory Access Protocol is OpenLDAP Software.
The LDAP server provides the account information through the use of PAM and NSS with
libnss-ldap packages for the Debian system. Several actions are required to enable this (I have not used this setup and the following is purely secondary information. Please read this in this context.):
/etc/pam.d/" directory to use "
pam_ldap.so" instead of the default "
/etc/nsswitch.conf" file to use "
ldap" instead of the default ("
compat" or "
/etc/pam_ldap.conf" as the configuration file for
/etc/pam_ldap.secret" as the file to store the password of the root.
/etc/libnss-ldap.conf" as the configuration file for
libpam-ldapto use SSL (or TLS) connection for the security of password.
libnss-ldapto use SSL (or TLS) connection to ensure integrity of data at the cost of the LDAP network overhead.
nscd(8) locally to cache any LDAP search results in order to reduce the LDAP network traffic.
See documentations in
pam_ldap.conf(5) and "
/usr/share/doc/libpam-doc/html/" offered by the
libpam-doc package and "
info libc 'Name Service Switch'" offered by the
Similarly, you can set up alternative centralized systems with:
This is the famous phrase at the bottom of the old "
info su" page by Richard M. Stallman. Not to worry: the current
su command in Debian uses PAM, so that one can restrict the ability to use
su to the
root group by enabling the line with "
pam_wheel.so" in "
libpam-cracklib package will enable you to force stricter password rule, for example, by having active lines in "
password required pam_cracklib.so retry=3 minlen=9 difok=3 password required pam_unix.so use_authtok nullok md5
password required pam_cracklib.so retry=3 minlen=9 difok=3 password [success=1 default=ignore] pam_unix.so use_authtok nullok md5 password requisite pam_deny.so password required pam_permit.so
sudo(8) is a program designed to allow a sysadmin to give limited root privileges to users and log root activity.
sudo requires only an ordinary user's password. Install
sudo package and activate it by setting options in "
/etc/sudoers". See configuration example at "
My usage of
sudo for the single user system (see Section 1.1.12, “sudo configuration”) is aimed to protect myself from my own stupidity. Personally, I consider using
sudo a better alternative to using the system from the root account all the time. For example, following will change the owner of "
<some_file>" to "
$ sudo chown <my_name> <some_file>
Of course if you know the root password (as self-installed Debian users do), any command can be run under root from any user's account using "
Security-Enhanced Linux (SELinux) is a framework to tighten privilege model tighter than the ordinary Unix-like security model with the mandatory access control (MAC) policies. The root power may be restricted under some conditions.
The Internet super-server,
inetd(8), is started at boot time by "
/etc/rc2.d/S20inetd" (for RUNLEVEL=2), which is a symlink to "
inetd allows one running daemon to invoke several others, reducing load on the system.
Whenever a request for service arrives, its protocol and service are identified by looking them up in the databases in "
/etc/protocols" and "
inetd then looks up a normal Internet service in "
/etc/inetd.conf", or a Sun RPC based service in "
For system security, make sure to disable unused services in "
/etc/inetd.conf". Sun RPC services need to be active for NFS and other RPC based programs.
inetd does not start the intended server directly but starts the TCP wrapper program,
tcpd(8), with the intended server name as its argument in "
/etc/inetd.conf". In this case,
tcpd runs the appropriate server program after logging the request and doing some additional checks using "
/etc/hosts.deny" and "
If you have problems with remote access in a recent Debian system, comment out "
ALL: PARANOID" in "
/etc/hosts.deny" if it exists.
For details, see
For more information on Sun RPC, see
portmap(8), and "
There are also non-PAM based access control available for
The information here may not be sufficient for your security needs but it should be a good start.
Many popular transportation layer services communicate messages including password authentication in the plain text. It is very bad idea to transmit password in the plain text over the wild Internet where it can be intercepted. You can run these services over "Transport Layer Security" (TLS) or its predecessor, "Secure Sockets Layer" (SSL) to secure entire communication including password by the encryption.
Table 4.7. List of insecure and secure services and ports.
|insecure service name||port||secure service name||port|
|smtp (mail)||25||ssmtp (smtps)||465|
The encryption costs CPU time. As a CPU friendly alternative, you can keep communication in plain text while securing just password with the secure authentication protocol such as "Authenticated Post Office Protocol" (APOP) for POP and "Challenge-Response Authentication Mechanism MD5" (CRAM-MD5) for SMTP and IMAP. (For sending mail messages over the Internet to your mail server from your mail client, it is recently popular to use new message submission port 587 instead of traditional SMTP port 25 to avoid port 25 blocking by the network provider while authenticating yourself with CRAM-MD5.)
The Secure Shell (SSH) program provides secure encrypted communications between two untrusted hosts over an insecure network with the secure authentication. It consists of the OpenSSH client,
ssh(1), and the OpenSSH daemon,
sshd(8). This SSH can be used to tunnel the insecure protocol communication such as POP and X securely over the Internet with the port forwarding feature.
The client tries to authenticate itself using host-based authentication, public key authentication, challenge-response authentication, or password authentication. The use of public key authentication enables the remote password-less login. See Section 6.9, “The remote access server and utility (SSH)”.
Even when you run secure services such as Secure Shell (SSH) and Point-to-point tunneling protocol (PPTP) servers, there are still chances for the break-ins using brute force password guessing attack etc. from the Internet. Use of the firewall policy (see Section 5.8, “Netfilter infrastructure”) together with the following secure tools may improve the security situation.
Table 4.8. List of tools to provide extra security measures.
small port-knock daemon
||V:1.5, I:2||432||an utility to help sysadmins thwart ssh hackers|
||V:3, I:4||554||bans IPs that cause multiple authentication errors|
||V:0.01, I:0.05||172||locks out remote attackers trying password guessing|
To prevent people to access your machine with root privilege, you need to:
With physical access to hard disk, resetting the password is relatively easy;
/etc/passwd" in the root partition and make the second entry for the
If you have the edit access to the GRUB menu entry (see Section 3.3, “Stage 2: the boot loader”) for
grub-rescue-pc at the boot time, it is even easier:
root=/dev/hda6 rw init=/bin/sh".
/etc/passwd" and make the second entry for the
The root shell of the system is now accessible without password.
Once you have root shell access, you can compromise password for all user accounts using brute force password cracking tools such as
The only reasonable software solution to avoid all these concerns is to use software encrypted root partition (or "
/etc" partition) using dm-crypt and initramfs (see Section 9.4, “Data encryption tips”). You always need password to boot the system, though.