메뉴 건너뛰기

SayClub.org

리눅스(Linux)

원문출처 : https://tech.chhanz.xyz/linux/2021/07/16/authselect-use-faillock/

 

[Linux] authselect 을 이용하여 faillock module 적용

RHEL v8 이후 변경점 RHEL v8 계열(CentOS/Oracle Linux/Rocky Linux) 부터는 이전과 같이 PAM 을 수정하여 설정하는 것을 권장하지 않습니다. [root@chhanz-c8-vm ~]# cat /etc/pam.d/system-auth ... # Generated by authselect on Fri J

tech.chhanz.xyz

 

RHEL v8 이후 변경점

RHEL v8 계열(CentOS/Oracle Linux/Rocky Linux) 부터는 이전과 같이 PAM 을 수정하여 설정하는 것을 권장하지 않습니다.

[root@chhanz-c8-vm ~]# cat /etc/pam.d/system-auth 
...
# Generated by authselect on Fri Jul 16 13:13:24 2021
# Do not modify this file manually.                      <<<
...

추가로 RHEL v8 계열부터는 기존에 사용하던 보안 설정으로 많이 사용 되던 pam_tally2 module 이 deprecated 되었습니다.
anthconfig 로 PAM 설정이 가능하였으나, RHEL v8 계열부터 authselect 을 사용하도록 변경 되었습니다.

 

authselect 이란?

 

authselect 는 특정 프로파일을 선택하여 시스템의 ID 및 인증 소스를 설정 할 수 있는 도구입니다.

 

authselect 사용법

 

Check current the profile

[root@chhan-rocky authselect]# authselect current 
Profile ID: sssd
Enabled features: None

Enable feature

faillock module 활성화.

[root@chhan-rocky authselect]# authselect enable-feature with-faillock 
Make sure that SSSD service is configured and enabled. See SSSD documentation for more information.

[root@chhan-rocky authselect]# authselect current 
Profile ID: sssd
Enabled features:
- with-faillock

Create the custom profile

sssd Profile 를 base 로 한 Profile 생성.

[root@chhan-rocky authselect]# authselect create-profile -b sssd security-profile
New profile was created at /etc/authselect/custom/security-profile

Change profile

[root@chhan-rocky security-profile]# authselect select custom/security-profile
Profile "custom/security-profile" was selected.
The following nsswitch maps are overwritten by the profile:
- passwd
- group
- netgroup
- automount
- services

Make sure that SSSD service is configured and enabled. See SSSD documentation for more information.

faillock module 을 이용한 보안 설정

 

기존에 pam_tally2등으로 주로 이용되던 계정 인증 실패에 대한 계정 잠금 정설이 faillock 으로 변경되면서 기능 활성화 및 정책 설정은 아래와 같이 해야됩니다.

 

faillock module 활성화

 

아래 명령을 통해 faillock module 을 활성화 합니다.

[root@chhanz-c8-vm ~]# authselect enable-feature with-faillock 
Make sure that SSSD service is configured and enabled. See SSSD documentation for more information.

[root@chhanz-c8-vm ~]# authselect current
Profile ID: sssd
Enabled features:
- with-fingerprint
- with-silent-lastlog
- with-faillock

faillock 정책 설정

 

아래와 같이 /etc/securrity/faillock.conf 를 수정합니다.
(Note: /etc/security/faillock.conf is available from pam-1.3.1-8.el8.)

[root@chhanz-c8-vm ~]# cat /etc/security/faillock.conf | grep -v "#"
dir = /var/run/faillock
audit
silent
deny = 4

faillock.conf 가 수정이 되면 변경된 profile을 적용합니다.

[root@chhanz-c8-vm ~]# authselect apply-changes 
Changes were successfully applied.

faillock 보안 설정 테스트

 

현재 적용한 정책은 기본적으로 4회 계정 인증 실패시 계정이 LOCK 되고 600s(Default value) 후에 UNLOCK 됩니다.

[root@chhanz-c8-vm ~]# ssh test@localhost
test@localhost's password: 
Permission denied, please try again.

위와 같이 계정 인증 실패시 faillock 명령을 통해 인증 실패 현황을 파악 할 수 있습니다.

[root@chhanz-c8-vm ~]# faillock 
root:
When                Type  Source                                           Valid
test:
When                Type  Source                                           Valid
2021-07-16 13:14:36 RHOST ::1                                                  V
2021-07-16 13:14:39 RHOST ::1                                                  V
2021-07-16 13:14:42 RHOST ::1                                                  V
2021-07-16 13:14:46 RHOST ::1                                                  V

/var/log/secure 에서 위와 같이 계정 LOCK 에 대한 로그를 확인 할 수 있습니다.

...
Jul 16 13:14:46 localhost unix_chkpwd[7186]: password check failed for user (test)
Jul 16 13:14:46 localhost sshd[7184]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=::1  user=test
Jul 16 13:14:46 localhost sshd[7184]: pam_faillock(sshd:auth): Consecutive login failures for user test account temporarily locked              <<<
...

실제로 4회 계정 인증 실패 후에는 계정 접근이 안되었고, 10분후에 다시 인증 시도를 할 수 있었습니다.

 

계정 잠금 해제

 

LOCK 된 계정을 수동으로 unlock 하는 방법은 아래와 같습니다.

[root@chhanz-c8-vm ~]# faillock --reset --user test
[root@chhanz-c8-vm ~]# faillock 
root:
When                Type  Source                                           Valid
test:
When                Type  Source                                           Valid

[참고] authselect 에서 지원하는 feature (profile sssd)

 

Feature NameDescription

with-faillock Lock the account after too many authentication failures.
with-mkhomedir Create home directory on user’s first log in.
with-ecryptfs Enable automatic per-user ecryptfs.
with-smartcard Authenticate smart cards through SSSD.
with-smartcard-lock-on-removal Lock the screen when the smart card is removed.
Requires that with-smartcard is also enabled.
with-smartcard-required Only smart card authentication is operative; others, including password, are disabled. Requires that with-smartcard is also enabled.
with-fingerprint Authenticate through fingerprint reader.
with-silent-lastlog Disable generation of pam_lostlog messages during login
with-sudo Enable sudo to use SSSD for rules besides /etc/sudoers.
with-pamaccess Refer to /etc/access.conf for account authorization.
without-nullock Do not add the nullock parameter to pam_unix

 

참고 자료

번호 제목 글쓴이 날짜 조회 수
75 우분투(Ubuntu) 서버 / Nginx, PHP, MariaDB 설치하고 설정하기 미르다테 2024.12.30 17
74 워드프레스 미디어 업로드 용량 제한 오류 해결 미르다테 2024.12.30 18
73 Nginx Reverse Proxy 사용시 IP 주소 전달 문제 해결하기 미르다테 2024.12.30 21
72 우분투(Ubuntu) 서버에 삼바(SAMBA) 설치하기 미르다테 2024.12.30 33
71 만자로(Manjaro) 리눅스 설치 후 초기 세팅 미르다테 2024.12.30 28
70 만자로(Manjaro) 리눅스 Pacman 사용법 미르다테 2024.12.30 23
69 Nginx Proxy Manager SSL 자동 갱신하기 미르다테 2024.12.30 29
68 우분투(Ubuntu) 서버 한글 폰트 설치하기 미르다테 2024.12.30 43
67 우분투(Ubuntu) 서버 지역시간설정(tzdata) 및 로케일(locale) 설정하기 미르다테 2024.12.30 56
66 우분투(ubuntu) 서버 유저명, 홈경로, 그룹명 변경 방법 미르다테 2024.12.30 41
65 CentOS 리눅스 YUM 사용법 미르다테 2024.12.30 48
64 CentOS 서비스 자동시작 설정 및 해제 미르다테 2024.12.30 67
63 CentOS 7에서 Docker 및 Docker Compose 설치하기 미르다테 2024.12.30 84
62 칼리 리눅스(Kali Linux)에 크롬(Chrome) 설치하기 미르다테 2024.12.30 69
61 우분투(Ubuntu)에서 일괄 업데이트하기 (불필요한 패키지 자동 삭제) 미르다테 2024.12.30 57
60 우분투(Ubuntu) 서버 보안 자동 업데이트 방법 미르다테 2024.12.30 71
59 CPU Governor 종류 미르다테 2024.12.30 85
58 그누보드5 게시판의 첨부파일 용량 제한과 관련된 PHP 설정 미르다테 2024.12.30 79
57 리눅스 로그파일 utmp, wtmp, btmp, last log, sulog 미르다테 2024.12.30 51
56 Virtualbox Centos 7 게스트확장설치 미르다테 2024.12.30 61
위로