当前位置: 移动技术网 > 网络运营>服务器>Linux > sshd 限制登陆的几种方法总结

sshd 限制登陆的几种方法总结

2019年04月24日  | 移动技术网网络运营  | 我要评论

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 drop
iptables -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登录

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网