根據(jù)以下的內(nèi)容來(lái)加固一臺(tái)Linux服務(wù)器的安全。
首先是限制連續(xù)密碼錯(cuò)誤的登錄次數(shù),由于RHEL8之后都不再使用pam_tally.so和pam_tally2.so,而是pam_faillock.so
首先進(jìn)入/usr/lib64/security/中查看有什么模塊,確認(rèn)有pam_faillock.so
因?yàn)橹幌拗苨sh登錄次數(shù)(一般本地登錄不會(huì)有問(wèn)題,故此只做ssh登錄次數(shù)限制)
然后可以直接編輯/etc/pam.d/password-auth,添加3行內(nèi)容:
auth required pam_env.so
auth required pam_faillock.so preauth silent audit (even_deny_root )deny=6 unlock_time=60//添加的第一行
auth sufficient pam_unix.so nullok try_first_pass
auth [default=die] pam_faillock.so authfail audit (even_deny_root )deny=6 unlock_time=60//添加的第二行
account required pam_unix.so
account required pam_faillock.so //添加的第三行
even_deny_root是包括把root的限制也加進(jìn)去,如果不需要的話可以刪去。
2.拆分管理員權(quán)限-新建一個(gè)賬戶并且添加管理員權(quán)限
設(shè)置了一個(gè)賬戶admin
新建一個(gè)賬戶
useradd admin
passwd admin
//輸入admin密碼
admin加入wheel用戶組
usermod -G wheel admin
然后修改權(quán)限
vim /etc/sudoers
Allow root to run any commands anywhere
root ALL=(ALL) ALL
admin ALL=(ALL) ALL
5.限制遠(yuǎn)程登錄的權(quán)限,即ssh權(quán)限,root用戶不允許通過(guò)ssh登錄
編輯/etc/ssh/sshd_config。
vim /etc/ssh/sshd_config 找到 PermitRootLogin
改為 PermitRootLogin no文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-621863.html
重啟 service sshd restart文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-621863.html
到了這里,關(guān)于安全加固服務(wù)器的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!