How to set the PAM module to control Linux Password policies

Source: Internet
Author: User
Article Title: how to set a Linux Password Policy for the PAM module. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

We often encounter this problem when using the linux system to set the password. The system prompts that your password is too simple, or your password is part of the dictionary. So how does the system check the complexity of users' passwords?

The system controls the password in two parts (I know:

1 cracklib

2 login. defs

Statement: login. defs mainly controls the password validity period. Manage the password time. I will not go into detail here

Login. defs -- shadow password suite configuration

Pam_cracklib.so is the key file to control password complexity.

Redhat specially developed the cracklib installation package to determine the password complexity.

You can view the rpm-ql cracklib

The judgment of password complexity is implemented through pam module control. The specific module is the parameter introduction of pam_cracklibpam_cracklib:

Debug

This option makes the module write information to syslog (3) indicating the behavior of the module (this option does not write password information to the log file ).

Type = XXX

The default action is for the module to use the following prompts when requesting passwords: "New UNIX password:" and "Retype UNIX password :". the default word UNIX can be replaced with this option.

Retry = N

Prompt user at most N times before returning with error. The default is 1

Difok = N

This argument will change the default of 5 for the number of characters in the new password that must not be present in the old password. in addition, if 1/2 of the characters in the new password are different then the new password will be accepted anyway.

Difignore = N

How many characters shocould the password have before difok will be ignored. The default is 23.

Minlen = N

The minimum acceptable size for the new password (plus one if credits are not disabled which is the default ). in addition to the number of characters in the new password, credit (of + 1 in length) is given for each different kind of character (other, upper, lower and digit ). the default for this parameter is 9 which is good for a old style UNIX password all of the same type of character but may be too low to exploit the added security of a md5 system. note that there is a pair of length limits in Cracklib itself, a "way too short" limit of 4 which is hard coded in and a defined limit (6) that will be checked without reference to minlen. if you want to allow passwords as short as 5 characters you shoshould not use this module.

Dcredit = N

(N> = 0) This is the maximum credit for having digits in the new password. if you have less than or N digits, each digit will count + 1 towards meeting the current minlen value. the default for dcredit is 1 which is the recommended value for minlen less than 10.

(N <0) This is the minimum number of digits that must be met for a new password.

Ucredit = N

(N> = 0) This is the maximum credit for having upper case letters in the new password. if you have less than or N upper case letters each letter will count + 1 towards meeting the current minlen value. the default for ucredit is 1 which is the recommended value for minlen less than 10.

(N> 0) This is the minimum number of upper case letters that must be met for a new password.

Lcredit = N

(N> = 0) This is the maximum credit for having lower case letters in the new password. if you have less than or N lower case letters, each letter will count + 1 towards meeting the current minlen value. the default for lcredit is 1 which is the recommended value for minlen less than 10.

(N <0) This is the minimum number of lower case letters that must be met for a new password.

Ocredit = N

(N> = 0) This is the maximum credit for having other characters in the new password. if you have less than or N other characters, each character will count + 1 towards meeting the current minlen value. the default for ocredit is 1 which is the recommended value for minlen less than 10.

(N <0) This is the minimum number of other characters that must be met for a new password.

Use_authtok

This argument is used to force the module to not prompt the user for a new password but use the one provided by the previusly stacked password module.

Dictpath =/path/to/dict

Path to the cracklib dictionaries.

Dictpath =/path/to/dict // note: the password dictionary is the key to verifying whether the user's password is part of the dictionary.

Path to the cracklib dictionaries.

Cracklib password strength detection process

First, check whether the password is part of the dictionary. If not, perform the following check:

Password strength detection process

These checks are:

Palindrome

Is the new password a palindrome of the old one?

Whether or not the old password is returned

Case Change Only

Is the new password the old one with only a change of case?

The new password is case-insensitive.

Similar

Is the new password too much like the old one?

Whether the new password is similar to the old one

This is primarily controlled by one argument, difok which is a number of characters that if different between the old and new are enough to accept the new password, this defaults to 10 or 1/2 the size of the new password whichever is smaller.

To avoid the lockup associated with trying to change a long and complicated password, difignore is available. this argument can be used to specify the minimum length a new password needs to be before the difok value is ignored. the default value for difignore is 23.

Simple

Is the new password too small?

Is the new password too short?

This is controlled by 5 arguments minlen, dcredit, ucredit, lcredit, and ocredit. See the section on the arguments for the details of how these work and there ults.

Rotated

Is the new password a rotated version of the old password?

Whether the character of the new password is a cycle of the character of the old password

For example, old password: 123

New Password 231

Already used

Was the password used in the past?

Have you used this password before?

Previusly used passwords are to be found in/etc/security/opasswd.

How does the system implement this control?

This line exists in the system configuration file/etc/pam. d/system-auth.

Password requisite pam_cracklib.so try_first_pass retry = 3

We can configure this pam module according to the parameters of pam_cracklib to achieve our goal.

Password required/lib/security/pam_cracklib.so retry = 3 type = minlen = 8 difok = 3 dictpath =/path/to/dict

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.