sshd 限制登陸的幾種方法總結
1. 在 /etc/hosts.allow 寫:
在/etc/hosts.allow寫:sshd: 1.2.3.4在 /etc/hosts.deny 寫:sshd: ALL
2. 用 iptables 也行:
iptables -I INPUT -p tcp --dport 22 -j DROPiptables -I INPUT -p tcp --dport 22 -s 1.2.3.4 -j ACCEPT
3. 禁止某個用戶通過ssh登錄
在/etc/ssh/sshd_conf添加AllowUsers 用戶名或者AllowGroups 組名或者DenyUsers 用戶名
4. 設定登錄黑名單
vi /etc/pam.d/sshd增加auth required /lib/security/pam_listfile.so item=user sense=deny file=/etc/sshd_user_deny_list onerr=succeed所有/etc/sshd_user_deny_list里面的用戶被拒絕ssh登錄
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
新聞熱點
疑難解答
圖片精選