为了生产服务器的安全,需要限制服务器允许登录的IP,增加安全性。
操作如下:
1. 设置允许的IP
vi /etc/hosts.allow
sshd:192.168.1.234:allow
vi /etc/hosts.deny
sshd:ALL
重启 service sshd restart
2. 允许某一个网段
vi /etc/hosts.allow
sshd:192.168.1.*:allow
vi /etc/hosts.deny
sshd:ALL
重启 service sshd restart
3. 限定用户同时限定IP
vi /etc/ssh/sshd_config
AllowUsers vilay@192.168.1.222 root@192.168.1.135 #多个IP用空格间隔