리눅스 패스워드 정책 설정 (CentOS 6.6 기준)

RedHat의 클론 OS인 CentOS는 클론답게 RedHat 리눅스와 90% 이상 동일합니다. 심지어 커널버전이 동일하다면 RedCastle과 같은 커널수준에서 동작하는 SW도 문제없이 실행이 될 정도입니다. 아마도…패스워드 규칙도 마찬가지이지 않을까 생각합니다.

패스워드 정책이라 함은…

비밀번호 길이는 최소 8자…

비밀번호는 영문 알파벳, 숫자(최소1개), 특수문자(최소1개)가 포함되어야 함…

비밀번호는 사용자ID가 포함될 수 없음…

비밀번호 변경 시 이전에 사용한 패스워드는 3개까지 사용 금지…

등등..

비밀번호를 만들 때 지켜야할 “최소한”의 규칙을 말합니다. 비밀번호 정책은 “최소한”의 규칙입니다.

리눅스도 이러한 비밀번호 규칙을 설정할 수 있습니다.

예전에는 아래 화면처럼 /etc/login.defs에서 이러한 규칙을 설정할 수 있었습니다.  (지금도 설정가능한지는 모르겠습니다만…안될거라고 예상되지만..)

리눅스 패스워드 정책 설정 (CentOS 6.6 기준)

최근에는 사용자 계정의 비밀번호 규칙을 설정하는 것이 조금 까다로워졌습니다. 바로 유닉스와 리눅스에서 공통으로 제공하는 플러그인 형태의 사용자 인증 모듈(PAM)에서 설정하도록 하고 있습니다.

PAM 모듈의 설정은 /etc/pam.d 에서 합니다. ssh remote(telnet), vsftpd 등 서비스별로 분리가 되어 있죠. 패스워드 규칙은 원래 passwd 라는 설정파일에서 정의하게 되어 있습니다. (아래 그림)

리눅스 패스워드 정책 설정 (CentOS 6.6 기준)

그런데 password 규칙은 system-auth 를 포함(include) 하도록 되어 있죠. 따라서 passwd 파일이 아닌 system-auth를 봐야 합니다. system-auth를 열어보면…다음과 같이 보입니다.

리눅스 패스워드 정책 설정 (CentOS 6.6 기준)

패스워드 규칙을 기본값으로 사용할 땐 위 이미지에서 주석처리(#) 된 행과같이 설정되어 있고 주석문 아래라인은 없습니다. retry 허용 횟수만 설정되어 있죠.

위 라인은 패스워드 변경 시에는 pam_cracklib.so 파일에 정의된 패스워드 규칙 검사 루틴을 호출하라는 뜻입니다. SO는 SharedObject (공유객체)의 의미로서 Windows의 DLL과 유사하다고 보면 됩니다. 리눅스와 유닉스에선 “공유 라이브러리”라고 부릅니다.

어쨌든 system-auth 파일을 위와같이 변경하고 테스트해보면 비밀번호를 12자 이상으로 설정(minlen=12)해야만 비밀번호 변경이 됩니다.

minlen과 같이 옵션으로 사용할 수 있는 항목들은 다음을 참고하면 됩니다.

Optionsdebug

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).

authtok_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 example word UNIX can be replaced with this option, by default it is empty.

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 character changes in the new password that differentiate it from the old password.

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 should 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.

minclass=N
The minimum number of required classes of characters for the new password. The default number is zero. The four classes are digits, upper and lower letters and other characters. The difference to the credit check is that a specific class if of characters is not required. Instead N out of four of the classes are required.

maxrepeat=N
Reject passwords which contain more than N same consecutive characters. The default is 0 which means that this check is disabled.

maxsequence=N
Reject passwords which contain monotonic character sequences longer than N. The default is 0 which means that this check is disabled. Examples of such sequence are ‘12345’ or ‘fedcb’. Note that most such passwords will not pass the simplicity check unless the sequence is only a minor part of the password.

maxclassrepeat=N
Reject passwords which contain more than N consecutive characters of the same class. The default is 0 which means that this check is disabled.

reject_username
Check whether the name of the user in straight or reversed form is contained in the new password. If it is found the new password is rejected.

gecoscheck
Check whether the words from the GECOS field (usualy full name of the user) longer than 3 characters in straight or reversed form are contained in the new password. If any such word is found the new password is rejected.

enforce_for_root
The module will return error on failed check also if the user changing the password is root. This option is off by default which means that just the message about the failed check is printed but root can change the password anyway.

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 previously stacked password module.

dictpath=/path/to/dict
Path to the cracklib dictionaries.

참고로 이 정책은 system-auth를 수정하고 저장한 뒤 다음번 passwd 명령을 실행할 때 바로 적용됩니다. 리부팅이나 재로그인이 필요하지 않습니다.

댓글 달기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

Scroll to Top