0 * * * * /root/black.sh
每一个小时执行一次,当一小时内出现超过3次登录失败,将此ip加入到黑名单中:
#!/bin/bash
for i in `lastb|awk '{print $3}' |sort|uniq -c|awk '$1>3 {print $2}'`
do
echo "sshd:$i" >> /etc/hosts.deny
done
echo > /var/log/btmp
0 * * * * /root/black.sh
每一个小时执行一次,当一小时内出现超过3次登录失败,将此ip加入到黑名单中:
#!/bin/bash
for i in `lastb|awk '{print $3}' |sort|uniq -c|awk '$1>3 {print $2}'`
do
echo "sshd:$i" >> /etc/hosts.deny
done
echo > /var/log/btmp