Created
May 14, 2017 12:14
This file contains hidden or 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 | |
# Fetch NEU SSH Black list to /etc/hosts.deny | |
# | |
# http://antivirus.neu.edu.cn/scan/ssh.php | |
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin | |
URL=http://antivirus.neu.edu.cn/ssh/lists/neu_sshbl_hosts.deny.gz | |
HOSTSDENY=/etc/hosts.deny | |
TMP_DIR=/dev/shm | |
FILE=hosts.deny | |
[ -d $TMP_DIR ] || TMP_DIR=/tmp | |
cd $TMP_DIR | |
curl --connect-timeout 60 $URL 2> /dev/null | gzip -dc > $FILE 2> /dev/null | |
LINES=`grep "^sshd:" $FILE | wc -l` | |
if [ $LINES -gt 10 ] | |
then | |
sed -i '/^####SSH BlackList START####/,/^####SSH BlackList END####/d' $HOSTSDENY | |
echo "####SSH BlackList START####" >> $HOSTSDENY | |
cat $FILE >> $HOSTSDENY | |
echo "####SSH BlackList END####" >> $HOSTSDENY | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment