linux学习记录
分类:
2010-11-09 11:36:54
# Global swatch filter file
# To ignore a IP-range
# ignore /216\.239\.37\./
# Invalid SSH Login Attempts
watchfor /(: [iI]nvalid [uU]ser )(.*)( from ::ffff:)(.*)$/
throttle threshold=3,delay=0:1:0,key=$4
mail addresses=xxx\@vip.sina.com,subject="SSH:\ Invalid\ User\ Rule1\ $4"
exec "/sbin/iptables -A swatch_rejects -s $4 -j DROP"
# Failed SSH Login Attempts
watchfor /(: [fF]ailed password for )(.*)( from ::ffff:)(.*)( port )(.*)$/
throttle threshold=3,delay=0:1:0,key=$4
mail addresses=xxxx\@vip.sina.com,subject="SSH:\ Invalid\ User\ Rule2\ $4"
exec "/sbin/iptables -A swatch_rejects -s $4 -j DROP"
# Invalid SSH Login Attempts. Another one - just formed differently
# watchfor /([aA]uthentication [fF]ailure; logname)(.*)(rhost=)(\d+\.\d+\.\d+\.\d+)(.*)$/
# throttle threshold=3,delay=0:1:0,key=$4
# mail addresses=xxxx\@vip.sina.com,subject="SSH:\ Invalid\ User\ Rule3\ $4"
# exec "/sbin/iptables -A swatch_rejects -s $4 -j DROP"
#!/bin/bash
#
# swatch This shell script enables the automatic use of YUM
#
# Author: Seth Vidal
#
# chkconfig: 2345 11 91
#
# description: Enable daily run of yum, a program updater.
# processname: swatch
# config: /etc/swatch/ssh-swatch.conf
pid=`/bin/ps -e -o cmd,pid | /bin/grep ^swatch | /bin/awk '{print $2}'`
case "$1" in
'start')
# start the swatch process
if [ "$pid" != "" ];
then
echo 'Swatch System is already initialized.'
exit 0
fi
if [ -f /usr/bin/swatch -a -f /etc/swatch/ssh-swatch.conf ];
then /usr/bin/swatch --config-file=/etc/swatch/ssh-swatch.conf --tail-file=/var/log/messages --tail-args='--follow=name --lines=1' --pid-file=/var/run/swatch.pid --daemon &
exit
fi
echo 'Swatch System startup complete.' ;;
'stop')
#stop all swatch processes
if [ "$pid" != "" ];
then kill -TERM $pid
##/usr/bin/killall tail
echo 'Swatch System shutdown complete.'
else
echo 'No Swatch System initialized.'
fi ;;
*)
echo "Usage: /etc/init.d/swatch { start | stop }" ;;
esac