天天看点

ssh限制用户访问

限制访问IP可用如下两种方法:

1、利用/etc/hosts.allow

一般情况sshd 不受 xinetd 管,但可支持 tcpd 。 因此可在 hosts.allow 中设: sshd: 192.168.0. sshd: ALL: deny

2、配置 iptables  iptables -I INPUT -p tcp --dport 22 -j DROP iptables -I INPUT -p tcp --dport 22 -s 192.168.0.0/32 -j ACCEPT (注:用参数 -I ,两语句顺序不能颠倒)

限制用户访问可用如下方法:

1、请 man sshd_config 找找 AllowGroups 与 AllowUsers 设定。 2、用 pam  1) 修改 /etc/pam.d/sshd auth required pam_listfile.so item=user sense=allow file=/etc/sshusers onerr=fail 2) 将你要的用户写进 /etc/sshusers ,如: echo "root" >> /etc/sshusers

转载于:https://blog.51cto.com/wuhaoshu/401106

继续阅读