암호의 복잡성
사용자의 암호 정책(Password Aging)를 설정하는 방법
전역) /etc/login.defs
로컬) chage CMD, /etc/shadow
Password Aging 관리
시스템 보안을 위해 사용자 패스워드 만기일을 설정 및 변경하는 명령어
password age
(1) chage CMD
# chage [Options] user
(명령어 사용 예) * # chage --help
# chage -M 30 -W 7 user01 -M : Max chage, -W : Warn date
# chage -E 2010-03-30 user01 -E : Expire date
# chage -l user01 -l : list
(/etc/shadow)
user01:$1$eG0hsAqw$Cfawvh5OsIye2rKYcRPH.0:
Last Change:MIN:MAX:WARN:INATIVE:Expire Date:
user01:$1$eG0hsAqw$Cfawvh5OsIye2rKYcRPH.0:14650:0:99999:7:::
user01:$1$eG0hsAqw$Cfawvh5OsIye2rKYcRPH.0:14650:30:90:7:30:15000:
1 : 암호화 알고리즘(1: MD5)
eG0hsAqw : salt key
Cfawvh5OsIye2rKYcRPH.0 : 암호화된 암호(password)
Last Change : 암호가 변경된 날짜를 일수로 환산(기준시간), 1970년 1월1일
Min Change : 암호를 변경할 수 없는 최소 날짜
Max Change : 암호를 변경 사용할 수 있는 최대 날짜
Wan Date : 경고 메세지를 주는 기간(Max Change)
Inactive : 암호를 비활성화 하는 기간(Max Change)
Expire Date : 암호를 사용할 수 있는 최대 날짜(절대값)
[EX1] 패스워드 변경후 다시 변경할 수 있는 최소 날짜(Min Chage 설정)
(전제조건) user01/user02/user03 사용자가 존재해야 한다.
- 기존의 사용자 모두 삭제(user01, user02, user03, ..... user100, user101)
# userdel -r user01
[참고] 사용자 삭제
------------------------------------------------
# for U_NAME in `awk -F: '$3 > 499 && $3 < 60000 {print $1}' /etc/passwd`
do
userdel -r $U_NAME
sleep 1
done
------------------------------------------------
- 새로운 사용자 추가(user01, user02, user03)
# useradd user01
# echo user01 | passwd --stdin user01
[참고] 사용자 추가
------------------------------------------------
# for U_NAME in user01 user02 user03
do
useradd $U_NAME
echo $U_NAME | passwd --stdin $U_NAME
done
------------------------------------------------
# chage -l user01
Last password change : Feb 10, 2010
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
# cat /etc/shadow | grep user01
user01:$1$2m3GgTgT$bM5ZxsZqpCi/hkPV0Ytpe.:16129:0:99999:7:::
# chage -m 7 user01 /* -m : MIN Change */
# chage -l user01
Last password change : Apr 01, 2010
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 7
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
# telnet localhost
user01 사용자로 로그인
$ passwd
Changing password for user user01.
Changing password for user01
(current) UNIX password: (user01)
You must wait longer to change your password <--- 사용자는 7일이전에 암호를 변경할 수 없다.
passwd: Authentication token manipulation error
$ exit
# grep user01 /etc/shadow
user01:$1$6.SEUwAq$lgBNtj6Q0XTp3VknOCyA01:16944:7:99999:7:::
[EX2] 패스워드 변경 후 다시 변경할 수 있는 최소 날짜(MAX Chage 설정)
# chage -M 30 user02 /* -M : MAX Change */
# chage -l user02
Last password change : Mar 01, 2010
Password expires : Mar 31, 2010
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 30
Number of days of warning before password expires : 7
현재(암호가 변경된 날짜)
|
| 30(MAX)
| |
|-----------+--------------+-------------+---
| |7(WARN)|
3월2일 4월2일
# date
Mon Mar 1 23:06:44 KST 2010
# date 03282306 (03월28일 23:06)
Sun Mar 28 23:06:00 KST 2010
# telnet localhost
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
linux101.example.com (Linux release 2.6.18-164.11.1.el5 #1 SMP Wed Jan 20 07:39:04 EST 2010) (4)
login: user02
Password: (user02 사용자 암호 입력)
[Warning: your password will expire in 3 days]
$ exit
# chage -l user02
Last password change : Mar 01, 2010
Password expires : Mar 31, 2010
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 30
Number of days of warning before password expires : 7
# date 04202306 (04월20일 23:06)
Tue Apr 20 23:06:00 KST 2010
# telnet localhost
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
linux101.example.com (Linux release 2.6.18-164.11.1.el5 #1 SMP Wed Jan 20 07:39:04 EST 2010) (4)
login: user02
Password: user02
[You are required to change your password immediately (password aged)]
[Changing password for user02]
(current) UNIX password: user02
New UNIX password: (새로운 암호 입력 : acbd1324)
Retype new UNIX password: (새로운 암호 입력 : acbd1324)
Last login: Sun Mar 28 23:06:51 from linux101
$ exit
#
[참고] rdate 명령어 사용법
# rdate -p time.bora.net /* -p : peer */
# rdate -s time.bora.net /* -s : setting */
# rdate -s time.bora.net
# date
-> 시스템 시간 복구
# chage -E 2010-11-30 user03 /* -E : Expire Date */
# chage -l user03
Last password change : Mar 02, 2010
Password expires : never
Password inactive : never
Account expires : Nov 30, 2010
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
# date 12301200 (12월30일 12:00)
Tue Dec 30 12:00:00 KST 2010
# telnet localhost
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
linux101.example.com (Linux release 2.6.18-164.11.1.el5 #1 SMP Wed Jan 20 07:39:04 EST 2010) (4)
login: user03
Password:(사용자 암호 입력)
[Your account has expired; please contact your system administrator]
Login incorrect
Connection closed by foreign host.
# grep user /etc/shadow
user01:$1$6YRLZe7X$Wq2IPhlAPCe.aiRU.bw.t1:14670:7:99999:7:::
user02:$1$NnSNmm9/$XrmbouuCWFxPjvrr4UKvP/:14719:0:30:7:::
user03:$1$wCwjYBvI$zdKUYhOks6c9Hu3Ejw5nr1:14670:0:99999:7::14943:
# chage -E "" user03
# chage -l user03
(복원) user01, user02, user03 삭제하고 새로 생성(user01, user02, user03)
(사용자 삭제 형식)
# userdel -r user01
(사용자 추가 형식)
# useradd user01
# passwd user01 (# echo user01 | passwd --stdin user01)
[참고] 사용자 삭제
------------------------------------------------
# for U_NAME in `awk -F: '$3 > 499 && $3 < 60000 {print $1}' /etc/passwd`
do
userdel -r $U_NAME
sleep 1
done
------------------------------------------------
- 새로운 사용자 추가(user01, user02, user03)
# useradd user01
# echo user01 | passwd --stdin user01
[참고] 사용자 추가
------------------------------------------------
# for U_NAME in user01 user02 user03
do
useradd $U_NAME
echo $U_NAME | passwd --stdin $U_NAME
done
------------------------------------------------
시간 복원 작업
# rdate -p time.bora.net
# date
# rdate -s time.bora.net
# date
'Learning > └◆리눅스 서버 보안' 카테고리의 다른 글
01_불 필요한 계정 삭제 (0) | 2017.02.20 |
---|---|
01_/etc/pam.d/system-auth 보안설정 [pam.d 이해] (0) | 2017.02.19 |
리눅스 서버 보안 04_주요정보통신기반시설_패스워드 (0) | 2017.02.16 |
리눅스 서버 보안 03_주요정보통신기반시설_계정관리 (0) | 2017.02.16 |