메뉴 건너뛰기

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 Rocky Linux 및 NetworkManager를 사용한 정적 경로 설정 미르다테 2025.04.03 15
74 Ubuntu 22.04 LTS 패키지 업데이트 시 오류 해결 방법 미르다테 2025.02.19 22
73 우분투 리눅스(Ubuntu Linux)에서 Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details. 오류 해결 방법 미르다테 2025.02.09 27
72 연속적으로 명령 실행시키기 (;과 &와 &&의 차이) 미르다테 2025.02.03 37
71 내 공인IP 확인하기(스크립트) 미르다테 2025.02.02 21
70 리눅스 네트워크 설정(Debian 계열, Ubuntu) 미르다테 2025.01.16 25
69 우분투(Ubuntu) 리눅스 apt 패키지 설치 이력 확인 미르다테 2025.01.14 110
68 Rocky Linux 9 고정 라우팅 경로 설정 방법 미르다테 2025.01.10 115
67 Rocky Linux 9에 Webmin 설치하는 방법 미르다테 2025.01.07 107
66 라이믹스(Rhymix) 애드온 '링크 프리뷰' 설치정보 미르다테 2025.01.06 108
65 Rocky Linux 9에 FFmpeg를 설치하는 방법 미르다테 2025.01.06 100
64 Ubuntu 24.04에 Webmin을 설치하는 방법 미르다테 2024.12.31 96
63 Ubuntu 24.04 LTS에 Docker 설치하기 미르다테 2024.12.31 122
62 Rocky Linux Docker, Docker Compose 설치 방법 미르다테 2024.12.30 109
61 라이믹스(Rhymix) 백업 및 복원 방법 미르다테 2024.12.30 117
60 Rocky Linux - 라이믹스(Rhymix) 설치하기 미르다테 2024.12.30 89
59 Rocky Linux 비밀번호 입력 초과로 인한 계정잠김 확인 및 해제 방법 미르다테 2024.12.30 98
58 Arch Linux mirrorlist 갱신하기 미르다테 2024.12.30 112
57 [중요] RedHat 계열 리눅스 서버 취약점 조치 방법 정리 - MirDaTe 미르다테 2024.12.30 102
56 [Arch Linux] pacman을 사용하여 시스템 업그레이드 시 패키지 손상으로 인한 업그레이드 안되는 증상 해결방법 미르다테 2024.12.30 125
위로