Tested On Fedora 14
And Gsm Nokia X-05
And Gsm Nokia X-05
Linux Operating System, linux OS, Linux Tips, Linux Tricks, Linux, Linux Fundas,
Install the package with YUM = yum install swatch
Then create a swatch configuration file called /etc/swatchrc containing the following:
vi /etc/swatchrc
# Bad login attempts watchfor /Failed password for/ exec "/usr/local/nix/scripts/bad_user $1 $2 $3 \
$4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15"
:wq!
Then create The Script with the following
vi /usr/local/nix/scripts/bad_user
#! /bin/bash # IP=`echo $* | sed 's/^.* from //' | awk '{print $1}' | sed 's/::ffff://'` ATTEMPTS=`grep $IP /var/log/secure | grep "Failed password for" | wc -l` if [ $ATTEMPTS -gt 2 ] then route add $IP lo MINUTES=`expr $ATTEMPTS - 2` echo "route del $IP lo 2> /dev/null" | at now +$MINUTES \
minutes 2>&1 > /tmp/.bad_user.$$ (hostname ; echo $* ; echo "IP=$IP" ; echo "ATTEMPTS=$ATTEMPTS" ; echo "Blocking for $MINUTES minutes" ; cat /tmp/.bad_user.$$ ) | Mail -s "bad user" Admin fi rm -f /tmp/.bad_user.$$
:wq!
Then start the swatch
swatch --config-file=/etc/swatchrc --tail-file=/var/log/secure \
--awk-field-syntax --tail-args "-F" &
yum install ssmtp
vi /etc/ssmtp/ssmtp.conf
AuthUser=username@gmail.com AuthPass=Your-Gmail-Password FromLineOverride=YES mailhub=smtp.gmail.com:587 UseSTARTTLS=YES
:wq!
make sure sendmail is disabled
# service sendmail stop
# chkconfig sendmail off
# mkdir /bakup
# mv /usr/sbin/sendmail /bakup
# ln -s /usr/sbin/ssmtp /usr/sbin/sendmail
echo "This is a test" | mail -s "Test" user@domain.com
#######################################################
to get alerts when root logins
add the followings in .bash_profiles in the root home
vi .bash_profile
echo 'ALERT - Root Shell Access on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" user@domain.com
:wq!
vi /etc/httpd/conf/httpd.conf
LoadModule proxy_module mod_proxy.so LoadModule proxy_http_module mod_proxy_http.so LoadModule proxy_balancer_module mod_proxy_balancer.so
ProxyRequests OffOrder deny,allow Deny from all