Pages

Monday, May 12, 2014

Postfix Virtual mailbox for a user

(1) Create a system user and set password.
Here it is: linux

(2) Install postfix

#yum install postfix

(3) Made the following changes in the postfix configuration

mydestination = $myhostname, $mydomain, example.com
virtual_alias_maps = hash:/etc/postfix/virtual

(4) Specify the virtual mailbox in the file.

root@server]#tail -2 /etc/postfix/virtual

mail@example.com linux
                                                                    VIRTUAL(5)
[root@server]#

Saturday, May 3, 2014

Check Load average with OpenVZ

#!/bin/bash
# This script checks the load average for the vps and reboot it if any of the vps load average goes higher than 7

load=`/usr/sbin/vzlist -o veid,laverage | /bin/sort -nrk 2 | awk '{ print $2 }' | cut -d / -f 1 | /usr/bin/head -1 | awk '{ print $1 }' | cut -d . -f 1`
if [ "$load" -gt "7" ]
then
line=`/usr/sbin/vzlist -o veid,laverage | /bin/sort -nrk 2 | /usr/bin/head -1 | awk '{ print $1 }'`
/usr/sbin/vzctl restart $line 2>/dev/null 1>&2
mail -s "The VPS $line has been rebooted due to the high load on the server $HOSTNAME"    alert@domain.com
fi

Friday, May 2, 2014

Wednesday, April 30, 2014

Group Install: iftop,multitail,sysstat,rkhunter


#!/bin/bash
if [ ! -f /bin/mail ];
then
yum -y install mailx
fi
cd /root
rm -rf rkhunter-1.4.0.tar.gz
rm -rf rkhunter-1.4.0
wget http://pkgs.fedoraproject.org/repo/pkgs/rkhunter/rkhunter-1.4.0.tar...
tar -xzf rkhunter-1.4.0.tar.gz
cd rkhunter-1.4.0
./installer.sh --install
/usr/local/bin/rkhunter --versioncheck
/usr/local/bin/rkhunter --update
rm -rf /root/rkhunt
er-1.4.0
rm -rf /root/rkhunter-1.4.0.tar.gz
cd /etc/cron.daily/
echo '#!/bin/bash' >rkhunter.sh
echo '/usr/local/bin/rkhunter --versioncheck' >> rkhunter.sh
echo '/usr/local/bin/rkhunter --update' >> rkhunter.sh
echo '/usr/local/bin/rkhunter --cronjob --report-warnings-only | mail -s "Rkhunter daily scan results for `hostname`" root' >> rkhunter.sh
chmod 755 /etc/cron.daily/rkhunter.sh
yum install -y sysstat iotop libpcap
rpm -ih http://pkgs.repoforge.org/iftop/iftop-0.17-1.el6.rf.x86_64.rpm
rpm -ih http://pkgs.repoforge.org/multitail/multitail-5.2.9-1.el6.rf.x86_64.rpm

Chkrootkit Installation

#!/bin/bash
if [ ! -f /bin/mail ];
then
yum -y install mailx
yum -y install glibc-static
fi
cd /root
rm -rf chkrootkit-0.49
rm -rf chkrootkit-0.49.tar.gz
wget http://pkgs.fedoraproject.org/repo/pkgs/chkrootkit/chkrootkit-0.49.tar.gz/304d840d52840689e
0ab0af56d6d3a18/chkrootkit-0.49.tar.gz
tar -xzf chkrootkit-0.49.tar.gz
rm -rf chkrootkit-0.49.tar.gz
cd /root/chkrootkit-0.49
make sense
cd /etc/cron.daily/
echo '#!/bin/bash' >chkrootkit.sh
echo 'cd /root/chkrootkit-0.49' >> chkrootkit.sh
echo './chkrootkit| grep INFECTED |
grep -v 465 | mail -s "Chkrootkit weekly scan results for
`hostname`" root' >> chkrootkit.sh
chmod 755
/etc/cron.weekly/chkrootkit.sh