- 限制指定IP地址登陆
# vim /etc/hosts.allow最后一行加入:
`sshd:192.168.0.*:allow //指定网段可用星号模糊匹配,单个ip则配置精确地址`
# vim /etc/hosts.deny最后一行加入:
`sshd:ALL //除了上面允许登录的IP,其它IP都拒绝登录`
systemctl restart sshd
- 限制指定用户登陆
# vim /etc/ssh/sshd_config最后一行加入 `AllowUsers keyso@192.168.0.222 root@192.168.1.135 //多个用户名@IP之间使用空格分隔` systemctl restart sshd