Setting up stronger password policy rules in Linux
Increased password security is no longer an optional item in setting up a secure system. Many external organizations (such as PCI) are now mandating security policies that can have a direct effect on your systems. By default, the account and password restrictions enabled on a Linux box are minimal at best. To better secure your hosts and meet those requirements from external vendors and organizations, here’s a small how-to on setting up stronger password and account policies in Linux. This is targeted at RHEL so other distributions may or may not be 100% compatible.As an example, let us assume that our security department has created an account security policy document. This document identifies both account and password restrictions that are now going to be required for all accounts both existing and new.
The document states that passwords must:
- Be at least 8 characters long.
- Use of at least one upper case character.
- Use of at least one lower case character.
- Use of at least one special character (!,@#$%, etc)
- Warn 7 days prior to expiration.
- Expire after 90 days
- Lock after 97 days.
redhat-config-users
GUI, you’re going to have to make the changes manually. Since our
server systems don’t run X, we will be making the changes directly to
the system without the help of the GUI.In RHEL, changes are made in multiple locations. They are:
- /etc/pam.d/system-auth
- /etc/login.defs
- /etc/default/useradd
/etc/pam.d/system-auth
is the PAM file responsible for authentication and where we will make our first modifications. Inside /etc/pam.d/system-auth
there are entries based on a “type” that the rules apply to. As we are only discussing password rules, you will see a password
type.password requisite /lib/security/$ISA/pam_cracklib.so retry=3
pam_cracklib
to meet our specifications we need to modify the line accordingly:- Minimum of 8 characters:
minlen=8
- At least one upper case character:
ucredit=-1
- At least one lower case character:
lcredit=-1
- At least one special character:
ocredit=-1
/etc/pam.d/system-auth
will now look like this:#password requisite /lib/security/$ISA/pam_cracklib.so retry=3 password requisite /lib/security/$ISA/pam_cracklib.so retry=3 minlen=8 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1
/etc/login.defs
file.# Password aging controls:# # PASS_MAX_DAYS Maximum number of days a password may be used. # PASS_MIN_DAYS Minimum number of days allowed between password changes. # PASS_MIN_LEN Minimum acceptable password length. # PASS_WARN_AGE Number of days warning given before a password expires. # PASS_MAX_DAYS 90 PASS_MIN_DAYS 0 PASS_MIN_LEN 8 PASS_WARN_AGE 7
PASS_MIN_LEN
is also set here as well.
Since we have been given some latitude on when to warn users we have
chosen to warn users seven days prior to expiration. But our last item
is curiously missing. Where do we set up the accounts so that after 97
days the account is locked out and requires a system administrator to
unlock?Believe it or not
useradd
controls the initial locking of an account. Issuing a useradd -D
will show you the current default paramters that are used when useradd is invoked.[root@host ~]# useradd -D GROUP=100 HOME=/home INACTIVE=-1 EXPIRE= SHELL=/bin/bash SKEL=/etc/skel CREATE_MAIL_SPOOL=yes
INACTIVE=-1
entry defines when an account will be
deactivated. Inactive is defined as the, “number of days after a
password has expired before the account will be disabled.” Our
requirements state that the account should be disabled seven days after
account expiration. To set this we can either:- Invoke
useradd -D -f 7
- Modify
/etc/default/useradd
and change theINACTIVE
entry.
In the next installment I’ll show you how to make our modifications effective on existing user accounts…
Great Jobs!!!!
ReplyDeleteI am looking for the answer to
ReplyDeleteIn the next installment I’ll show you how to make our modifications effective on existing user accounts…
While the "minlen" parameter controls the minimum password length, things are not as simple as they might appear. This is because pam_cracklib combines the notion of password length with password "strength" (the use of mixed-case and non-letter characters).
ReplyDelete"minlen" is actually the minimum required length for a password consisting of all lower-case letters. But users get "length credits" for using upper- and lower-case letters, numbers, and non-alphanumeric characters. The default is normally that you can only get a maximum of "1 credit" for each type of character. So if the administrator sets "minlen=12", a user could still have an 8 character password if they used all four types of characters. Actually, since using a lower-case letter gets you a credit, the real minimum length for an all lower-case password is minlen-1.
The maximum credit for any particular class of characters is actually customizable. The four parameters "lcredit", "ucredit", "dcredit", and "ocredit" are used to set the maximum credit for lower-case, upper-case, numeric (digit), and non-alphanumeric (other) characters, respectively. For example, you could add the following parameters on the pam_cracklib line in the /etc/pam.d/common-password file:
lcredit=0 ucredit=1 dcredit=1 ocredit=2
In other words, lower-case characters aren't special at all, so you get no credit there. On the other hand we give extra credit if the user puts two or more non-alphanumeric characters in their password. One point is still the max credit for upper-case characters and numbers. Note that no matter what you set "minlen" to and no matter how many "credits" you give to your users, pam_cracklib will never let users pick passwords with less than six characters--this is a hard-coded internal minimum.
Play around with these values and find something that makes sense for your site, but as a starting point I might recommend "minlen=12 difok=4" for machines using MD5 password hashes. This means that the smallest password a user could have is 8 characters, and that's only if they use all four character sets.
great review,
ReplyDeleteThanks a lot..
/kiran
Thank you for sharing such a wonderful Information !!
ReplyDeleteHere is a list of Top LINUX INTERVIEW QUESTIONS
Veritas Cluster Interview Questions
Redhat Cluster Suite Commands
SAMBA Server Interview Questions
Linux FTP vsftpd Interview Questions
SSH Interview Questions
Apache Interview Questions
Nagios Interview questions
IPTABLES Interview Questions
Ldap Server Interview Questions
LVM Interview questions
Sendmail Server Interview Questions
YUM Interview Questions
NFS Interview Questions
Tcpdump Command Examples & Usages
Example of YUM Commands
How to rewrite outgoing address in Postfix
Read More at :- Linux Troubleshooting