pam_fally2 でログイン失敗回数の制限
※こちらのページは断片的な情報のメモです。
※実際は、ここに記載されている設定以外も挙動に影響します。
sshからのログイン失敗回数を制限したい
設定ファイル
/etc/pam.d/sshd
pam_tally2
を使用してパスワード複数回失敗場合の動作を制御する
auth required pam_sepermit.so auth substack password-auth auth include postlogin auth [success=1 default=ignore] pam_succeed_if.so user in user1 # auth required pam_tally2.so deny=5 onerr=fail lock_time=600 serialize auth required pam_tally2.so deny=2 onerr=fail unlock_time=15 serialize
pam_tally2のパラメーター
deny=n
- Deny access if tally for this user exceeds n.
lock_time=n
- Always deny for n seconds after failed attempt.
unlock_time=n
- Allow access after n seconds after failed attempt. If this option is used the user will be locked out for the specified amount of time after he exceeded his maximum allowed attempts. Otherwise the account is locked until the lock is removed by a manual intervention of the system administrator.
auth [success=1 default=ignore] pam_succeed_if.so user in user1:user2:user3
- ログインに何度も失敗してもシステムがユーザーをロックアウトしないようにするには、/etc/pam.d/system-auth と /etc/pam.d/password-authの両方で、pam_faillock が初めて呼び出される行のすぐ上に次の行を追加します。また、user1、user2、よび user3を実際のユーザー名に置き換えてください。
失敗回数の確認・リセット
## 確認 pam_tally2 -u <user> Login Failures Latest failure From <user> 4 07/25/22 20:28:34 gateway ## リセット pam_tally2 -u <user> --reset
参考
第4章 ツールとサービスでシステムを強化する Red Hat Enterprise Linux 7 | Red Hat Customer Portal
* 4.1.2. アカウントのロック