Created
February 22, 2017 06:12
-
-
Save i-sync/d01b35cf67effb8db9384fa7bb9fd79c to your computer and use it in GitHub Desktop.
SSH-Failed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
SCANIP=`grep "Failed" /var/log/secure | awk '{print $(NF-3)}' | sort | uniq -c | awk '{print $1"="$2;}'` | |
for i in $SCANIP | |
do | |
NUMBER=`echo $i | awk -F= '{print $1}'` | |
SCANIP=`echo $i | awk -F= '{print $2}'` | |
echo "$SCANIP:$NUMBER" | |
if [ $NUMBER -gt 10 ] | |
then | |
grep $SCANIP /etc/hosts.deny >/dev/null 2>&1 || echo "sshd:$SCANIP" >> /etc/hosts.deny | |
echo "`date` $SCANIP $NUMBER" >> /var/log/scanip.log | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment