세션 차단(SSH - MaxAuthTries)과 계정 잠금(PAM - faillock) 비교
| 구분 | SSH의 MaxAuthTries | PAM의 faillock |
| 담당 구역 | 네트워크 원격 접속 창 (ssh 명령) | 리눅스 운영체제(OS) 자체 (su, 콘솔 등) |
| 제어 파일 | /etc/ssh/sshd_config | /etc/security/faillock.conf |
| 틀렸을 때 현상 | 접속 세션이 끊어짐 (팅겨나감) | 계정 자체가 락(Lock)이 걸림 |
| 해제 방법 | 그냥 ssh 명령을 다시 실행하면 됨 | root 계정으로 faillock --reset 해야 함 |
PAM 접속 잠금 설정
1. authselect로 베이스 프로필 활성화
CentOS 8, Rocky Linux 등 최신 리눅스 환경에서는 /etc/pam.d/system-auth 파일을 손으로 직접 수정하면 시스템이 꼬이거나 설정이 덮어써져 사라집니다. 대신 시스템이 제공하는 안전한 인증 프레임워크인 authselect 명령어를 사용해야 합니다.
아래 명령어를 실행하여 시스템이 계정 잠금 기능(with-faillock)을 마스터 설정으로 인식하게 하여 업데이트나 서비스 재시작 시 초기화 방지를 위해 템플릿에 강제로 주입하여 유지하는 명령입니다.
$ authselect select minimal with-faillock --force
2. faillock.conf에서 상세 규칙 설정(deny=3)
$ vi /etc/secureity/faillock.conf
- 3회 연속 인증 실패 시 계정 잠금
# Deny access if the number of consecutive authentication failures
# for this user during the recent interval exceeds n tries.
# The default is 3.
deny = 3
- 잠금 유지 시간 (120초 = 2분 뒤 자동 해제)
# The access will be reenabled after n seconds after the lock out.
# The value 0 has the same meaning as value `never` - the access
# will not be reenabled without resetting the faillock
# entries by the `faillock` command.
# The default is 600 (10 minutes).
unlock_time = 120
- 화면에 잠금 메시지를 숨겨 힌트를 주지 않음(보안 필수)
# Don't print informative messages.
# Enabled if option is present.
silent
PAM 설정은 서비스를 재시작할 필요 없이 저장 즉시 실시간으로 커널에 반영됩니다.
테스트
oracle 계정 접속 실패 3회 이상
[gwon@orcl ~]$ su - oracle
Password:
su: Authentication failure
[gwon@orcl ~]$ su - oracle
Password:
su: Authentication failure
[gwon@orcl ~]$ su - oracle
Password:
su: Authentication failure
[gwon@orcl ~]$ su - oracle
Password:
su: Authentication failure
[gwon@orcl ~]$ su - oracle
Password:
su: Authentication failure
oracle 계정 잠김 상태 확인
[oracle@orcl ~]$ faillock --user oracle
oracle:
When Type Source Valid
2026-05-27 01:22:47 TTY pts/0 V
2026-05-27 01:22:52 TTY pts/0 V
2026-05-27 01:22:57 TTY pts/0 V
- 접속 기록과 함께 잠김 상태 조회됨
'🐧 Linux_이야기' 카테고리의 다른 글
| [Linux] 리눅스 사용자 계정 잠김(PAM/SSH) (0) | 2026.05.27 |
|---|---|
| [Linux] SSH 서버 간 접속(ssh-keygen) (0) | 2026.02.25 |
| [Linux] 시간 동기화(Time Sync) (0) | 2026.02.05 |
| [Linux] Host-Only 네트워크가 안 잡히는 문제 (0) | 2026.01.29 |
| [Linux] SSH 접속 안 될 때 확인 (2) | 2026.01.08 |