OS

Linux 계정 암호 정책 설정

by LionHeart posted Jul 26, 2017
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄

Linux 계정 암호 정책 설정

A. 암호 길이 설정

  • CentOS 7.x
# authconfig --passminlen=8 --update
# grep "^minlen" /etc/security/pwquality.conf
minlen = 8
  • CentOS 6.x
# vi /etc/pam.d/system-auth
password    requisite     pam_cracklib.so try_first_pass retry=3 type=minlen=8

B. 암호 복잡도 설정

  • CentOS 7.x
적어도 1개의 소문자 사용
# authconfig --enablereqlower --update
# grep "^lcredit" /etc/security/pwquality.conf
lcredit = -1
적어도 1개의 대문자 사용
# authconfig --enablerequpper --update
# grep "^ucredit" /etc/security/pwquality.conf
ucredit = -1
적어도 1개의 숫자 사용
# authconfig --enablereqdigit --update
# grep "^dcredit" /etc/security/pwquality.conf
dcredit = -1
적어도 1개의 다른 문자 사용
# authconfig --enablereqother --update
# grep "^ocredit" /etc/security/pwquality.conf
ocredit = -1
  • CentOS 6.x
# vi /etc/pam.d/system-auth
password    requisite     pam_cracklib.so try_first_pass retry=3 type= minlen=8 dcredit=-1 ucredit=-1 lcredit=-1 ocredit=-1

C. 암호 사용 기간 설정

# vi /etc/login.defs
PASS_MAX_DAYS   100
PASS_MIN_DAYS 0
# PASS_MIN_LEN 5
PASS_WARN_AGE 7

100일 동안 암호를 사용할 수 있고, 암호 만료 7일 전에 알려 준다.

해당 내용은 새로 생성되는 유저에게 적용된다.

기존 유저는 다음 명령어를 실행해서 적용한다.

최대 사용기간
# chage -M <days> <username>
최소 사용기간
# chage -m <days> <username>
암호 만료 안내
# chage -W <days> <username>
확인 
# chage -l <username>
# chage -l vagrant
Last password change : never
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7

D. 이전 사용한 암호 기억

  • CentOS 6.x / CentOS 7.x
# vi /etc/pam.d/system-auth
password    sufficient    pam_unix.so sha512 shadow nullok try_first_pass use_authtok remember=5

E. 로그인 실패 시 계정 잠금

# vi /etc/pam.d/password-auth
auth        required      pam_tally2.so file=/var/log/tallylog deny=3 even_deny_root unlock_time=1200
auth required pam_env.so
auth sufficient pam_unix.so nullok try_first_pass
auth requisite pam_succeed_if.so uid >= 1000 quiet_success
auth required pam_deny.so
account     required      pam_unix.so
account sufficient pam_localuser.so
account sufficient pam_succeed_if.so uid < 1000 quiet
account required pam_permit.so
account required pam_tally2.so

계정 잠금 확인 및 잠금 해제

계정 로그인 실패 횟수 확인
# pam_tally2 -u vagrant
Login Failures Latest failure From
vagrant 4 03/07/17 15:17:30 10.0.2.1
계정 잠금 해제
# pam_tally2 -u vagrant -r
Login Failures Latest failure From
vagrant 4 03/07/17 15:17:30 10.0.2.1
# pam_tally2 -u vagrant
Login Failures Latest failure From
vagrant 0


URL: https://medium.com/@jongseonkim/linux-%EC%95%94%ED%98%B8-%EC%A0%95%EC%B1%85-%EC%84%A4%EC%A0%95-3c76ffebfdcb