今天使用Denyhosts时如果信任IP被屏蔽了,会不能登录,即使在/etc/hosts.allow添加了信任IP也没有效果,因为/etc/hosts.deny的优先级大于/etc/hosts.deny。
解决:
1. 编写定时去除/etc/hosts.deny文件中得信任IP
- vi /usr/local/bin/delete_denyhosts_allow.bash
- #!/bin/bash
- # set -x
- # ip可以是192.168.1.这种形式
- declare hostip='ip1 ip2 …'
- for ip in $hostip
- do
- sed -i "/$ip/d" /etc/hosts.deny
- done
2. 添加定时任务,每分钟清理一次
- crontab -e
- # delete allow ip from hosts.deny
- * * * * * /bin/bash /usr/local/bin/delete_denyhosts_allow.bash > /tmp/delete_denyhosts_allow.log 2>&1
暂时还没发现配置文件中能配置这种信任IP,应该会有的,先暂时这样子解决吧。
转载于:https://blog.51cto.com/linuxjcq/717915