Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Anti-brute force cracking sshd script

Shulou Source: shulou.com Published: 2022-06-01 07:44:52 11月26日 Update

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

Tags: Script address just in case password opportunity system run Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Redmi Microsoft vpn MariaDB