1)修改/etc/hosts.allow和/etc/hosts.deny 这两个文件,把需要通过的IP写在/etc/hosts.allow 文件里
[root@localhost ~]# cat /etc/hosts.allow
sshd:192.168.1.11:allow
[root@localhost ~]# cat /etc/hosts.deny
sshd:ALL
[root@localhost ~]# /etc/init.d/sshd restart #重启服务使配置生效
2)修改/etc/ssh/sshd_config文件
[root@localhost ~]# cat /etc/ssh/sshd_config
allowusers ywxi@192.168.1.11
allowusers root@192.168.1.11
denyusers ywxitest@192.168.1.11
[root@localhost ~]# /etc/init.d/sshd restart #重启服务使配置生效