Anti-brute force cracking sshd script
Note: This script does not periodically clean up IP addresses previously added to/etc/hosts.deny
Just in case, add your local ip address in/etc/hosts.allow, in case you forget the root password one day, there is a chance to try, otherwise it will be hehe.
This script runs on centos6 systems. If centos 7 needs it, you need to modify the script declaration (#!/ usr/bin/bash);
Step 1:
mkdir /date/script/ -p
vim /date/script/cron.sh
#!/ bin/bash
for ((i=1;i /tmp/reject.txt
for i in `cat /tmp/reject.txt`
do
ip=$i
grep -w "$ip" /etc/hosts.deny
if [ $? -gt 0 ]
then
echo "sshd:$ip" >> /etc/hosts.deny
fi
done
Step 3:
crontab -e
*/1 * * * * sh /date/script/cron.sh