一、登錄失敗處理功能策略
1、登錄失敗處理功能策略(服務(wù)器終端)
(1)編輯系統(tǒng)/etc/pam.d/system-auth 文件,在 auth 字段所在的那一部分添加如下pam_tally2.so模塊的策略參數(shù):
auth required pam_tally2.so onerr=fail deny=5 unlock_time=300 even_deny_root root_unlock_time=300
或者
auth required pam_tally2.so onerr=fail deny=5 unlock_time=300 no_magic_root
(2)pam_tally2.so模塊參數(shù)解讀:
onerr=fail? ? ? ? ?#表示連續(xù)錯(cuò)誤
deny=n? ? ? ? ? ? #表示連續(xù)登錄失敗次數(shù)超過(guò)n次后拒絕訪問(wèn)
unlock_time=300? ? ? #表示連續(xù)登錄失敗后鎖定的時(shí)間(秒數(shù))為300秒
no_magic_root? ? ? ? ?#表示連root用戶也在限制范圍內(nèi)
even_deny_root? ? ? ? #root用戶失敗登錄次數(shù)超過(guò)deny=n次后拒絕訪問(wèn)
root_unlock_time=300?? ? #與even_deny_root相對(duì)應(yīng)的選項(xiàng),如果配置該選項(xiàng),則root用戶在登錄失敗次數(shù)超出限制后被鎖定指定時(shí)間為300秒
注:用戶鎖定期間,無(wú)論在輸入正確還是錯(cuò)誤的密碼,都將視為錯(cuò)誤密碼,并以最后一次登錄為鎖定起始時(shí)間,若果用戶解鎖后輸入密碼的第一次依然為錯(cuò)誤密碼,則再次重新鎖定。
2、登錄失敗處理功能策略(ssh遠(yuǎn)程連接登錄)
(1)編輯系統(tǒng)/etc/pam.d/sshd文件,添加的內(nèi)容與服務(wù)器終端的一致。
?在 auth 字段所在的那一部分添加如下pam_tally2.so模塊的策略參數(shù):
auth required pam_tally2.so onerr=fail deny=5 unlock_time=300 even_deny_root root_unlock_time=300
或者
auth required pam_tally2.so onerr=fail deny=5 unlock_time=300 no_magic_root
(2)錯(cuò)誤處理:
如果在操作中間出現(xiàn)下面這個(gè)錯(cuò)誤:
Dec 7 15:06:51 iZ2zee7gmy40tbverl53rfZ sshd[15747]: PAM unable to dlopen(/lib64/security/pam_tally.so): /lib64/security/pam_tally.so: cannot open shared object file: No such file or directory
Dec 7 15:06:51 iZ2zee7gmy40tbverl53rfZ sshd[15747]: PAM adding faulty module: /lib64/security/pam_tally.so
上面的錯(cuò)誤意思是在/lib64/security/ 下面找不到pam_tally.so,而我進(jìn)入到目錄下,確實(shí)沒(méi)找到這個(gè)文件,解決方法是將現(xiàn)有的?pam_tally2.so做個(gè)軟連接到pam_tally.so。
[root@localhost ~]# cd /lib64/security/
[root@localhost security]# ln -s pam_tally2.so pam_tally.so
二、操作超時(shí)退出功能策略
(1)編輯/etc/profile系統(tǒng)文件,在文件后面添加:
export TMOUT=300? ? ? ?#表示無(wú)操作300秒后自動(dòng)退出
擴(kuò)展:
export TMOUT=0 #0代表永不自動(dòng)退出?
readonly TMOUT # 將值設(shè)置為readonly 防止用戶更改,在shell中無(wú)法修改TMOUT
(2)source /etc/profile 使修改生效。
文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-412321.html
?文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-412321.html
到了這里,關(guān)于linux設(shè)置登錄失敗處理功能(密碼錯(cuò)誤次數(shù)限制、pam_tally2.so模塊)和操作超時(shí)退出功能(/etc/profile)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!