본문 바로가기
ISMS-P/linux

리눅스서버 보안조치 2021 주통기반 (RHEL계열 7/8/9) 계정부분

by open_tracking 2021. 5. 12.

주요정보통신시설기반 리눅스 기술적 보안조치 2021 3월자 최신 기준입니다.

- 2023-03-17 수정

항목 부분 색깔 보시며 구분할 수 있게 하였습니다.

빨간색 글씨의 경우 default가 취약이므로 변경하셔야 되는 부분입니다.

검정색 글씨의 경우 default가 양호입니다.

바쁘시면 빨간 글씨만 보세요

 

1. root 계정 원격 접속 세션 제한 

- /etc/ssh/sshd_config 에서 PermitRootLogin no

 

2. 패스워드 복잡성 설정

- /etc/security/pwquality.conf

 

해당 부분 수정

아래 주석처리부분 해제하고 설정

 

# Minimum acceptable size for the new password (plus one if
# credits are not disabled which is the default). (See pam_cracklib manual.)
# Cannot be set to lower value than 6.

minlen = 8
#
# The maximum credit for having digits in the new password. If less than 0
# it is the minimum number of digits in the new password.
dcredit = -1
#
# The maximum credit for having uppercase characters in the new password.
# If less than 0 it is the minimum number of uppercase characters in the new
# password.
ucredit = -1
#
# The maximum credit for having lowercase characters in the new password.
# If less than 0 it is the minimum number of lowercase characters in the new
# password.
lcredit = -1
#
# The maximum credit for having other characters in the new password.
# If less than 0 it is the minimum number of other characters in the new
# password.
ocredit = -1

 

3. 계정 잠금 임계값 설정

- /etc/pam.d/system-auth

auth required  /usr/lib64/security/pam_faillock.so deny=5 unlock_time=120
account required  /usr/lib64/security/pam_faillock.so

4. 패스워드 파일 보호

- /etc/passwd 파일 부분

root:x:0:0:root:/root:/bin/bash 이부분에서 계정들 모두 :x: 형태로 나타나면 양호이며

x 대신 패스워드해쉬가 보이면 취약

 

pwconv 명령어와 pwunconv 로 방식을 오갈 수 있으며

pwconv 으로 적용하는 부분이 양호

 

5. root 이외의 UID가 '0' 금지

- /etc/passwd 파일 부분

예시 파란글씨 참조

root:x:0:0:root:/root:/bin/bash

bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin

 

6. root 계정 su 제한

- /etc/pam.d/su 파일 추가

(이미 추가된 항목들도 존재하니 주의)

su 사용할 그룹을 wheel이라고 가정합니다.(default로 생성된 그룹임)

auth            sufficient      pam_rootok.so
auth            required        pam_wheel.so debug group=wheel
auth            required        pam_wheel.so use_uid

# usermod --groups wheel 사용할해당ID 

예시 usermod --groups wheel hope201

 

* sudoers 와는 다른거에요~

 

7.  패스워드 최소 길이 설정

- /etc/login.defs

PASS_MIN_LEN    8

 

8.  패스워드 최대 사용기간 설정

- /etc/login.defs

PASS_MAX_DAYS   90

 

9.  패스워드 최소 사용기간 설정

- /etc/login.defs

PASS_MIN_DAYS   1

 

10. 불필요한 계정 제거

- /etc/passwd

 

퇴사자 계정 or ㅣlp uucp nuucp 계정 확인

 

RHEL 계열 8 리눅스에는 lp계정 존재 / 필자는 주석처리함.

 

로그인 기록은 주통메뉴얼에서는 cat /var/log/wtmp 하라고 나와있지만... 하지마세요 글자 깨집니다.
string /var/log/wtmp 로 보시거나.. 그냥 last 쳐서 보시면 됩니다.

 

11. 관리자 그룹에 최소한의 계정 포함

- /etc/group

양호한 예시

root:x:0:

 

왠만하면 root 그룹에 넣지마시고 sudo or su 활용하세요.

 

12. 계정이 존재하지 않는 GID 금지

- /etc/group , /etc/passwd 

해당 파일 참고하여 운용환경에 따라 상이함.

그룹생성하고 퇴사자 발생시 삭제하여 사용되지 않는 부분 삭제하였다면 무관

그룹생성자체를 수동으로 한적이 없다면 양호할 가능성이 큼.

 

13. 동일한 UID 금지

- /etc/passwd

 

고의로 동일한 UID로 계정생성을 하지 않았다면 

root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin

파란부분 숫자가 계정마다 다름 -> 이 경우 양호 

 

같은부분이 있다면 #usermod –u 변경할UID값 계정이름

 

14. 사용자 shell 점검

- /etc/passwd 

로그인이 필요하지 않은 계정은 /sbin/nologin 부여해야함.

 

#sync:x:5:0:sync:/sbin:/bin/sync
sync:x:5:0:sync:/sbin:/bin/nologin

#halt:x:7:0:halt:/sbin:/sbin/halt
halt:x:7:0:halt:/sbin:/sbin/nologin

 

이런식으로 변경함. 테스트 몇일 해보고 주석처리된것 삭제 예정...

 

15. Session Timeout

-/etc/profile

-/etc/csh.login

 

일반적으로 vi /etc/profile 열어서 최하단에 

TMOUT=600 추가

 

export TMOUT

 

 

만약 로그인이나 sudo 전환이나 이런문제가 생기면

/var/log/secure 확인해보세요.

댓글