grep command GREP command

ls -l | grep -i python  # -i  = case insensitive search

ls -l | grep -v "python"   # -v = invert the search , not matching element will be printed

# find . –name "*.mp3" | grep –i JayZ | grep –vi "remix" 

ps -ef | grep -c [h]ttpd  #count number of matching line

cat myfile.txt | grep -n "major12"  # print line number of matching line

cat myfile.txt | grep -w "NepalKTM"  #returns only "NepalKTM" match entire word only
 
cat apache.conf | grep -v "^#"  

check process status and start if it is not running using cron bash

[root@mx12 /]# cat /opt/checkclam.sh
#!/bin/bash
if ! pgrep clamd > /dev/null;
then
/etc/init.d/clamd restart > /dev/null;
else
echo "OK `date +%T\ %F`" >> /program.log; #'\ ' is for space use %t for tab
fi


[root@mx12 /]# crontab -l
*/3 * * * * /opt/checkclam.sh 


== == =====  ===== = =  =  === === ====    == =  ========= =
#!/bin/bash

# Check if gedit is running
if ps aux | grep "[h]ttdp" > /dev/null
then
    echo "Running"
else
    echo "Stopped"
fi
 
This script is just checking to see if the program "httpd" is running.
The square brackets are useful to avoid the output of the grep command. Without this the conditional will always return true, because the grep command start a process with the same content of the searched string.
 = = = =  = = = = = = = = =Check SELINUX and turn it to permissive  = = = = = = = = = = = = = =
#!/bin/bash
var1=`getenforce`
if [ "$var1" == "Permissive" ]
then
    :                             # the " : " colon will do nothing or NO operation
else
/usr/sbin/setenforce 0
fi
 
 
============
 
[root@mailvm /]# cat selinuxcheck 
#!/bin/bash
var1=`getenforce`
#if [ "$var1" == "Permissive" ] 
#then  
#    :
#else 
#/usr/sbin/setenforce 0 
#fi
if [ "$var1" == "Enforcing" ]
then
echo "enforced mode"
printf "Now changing to Permissive"
sleep 1
printf "."
sleep 1
printf "."
/usr/sbin/setenforce 0
else
echo "permissive mode [OK]"  
fi
echo
 
============================================================================= 

ICINGA check postfix mailq in icinga part 3

#icinga  #icinga

#vim /etc/nagios/nrpe.cfg

allowed_hosts=198.50.155.195,  127.0.0.1
command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200
command[check_mailq]=/usr/lib/nagios/plugins/check_mailq -w 300 -c 500

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
root@vps:/usr/lib/nagios/plugins# ls -l /usr/lib/nagios/plugins/check_mailq
-rwxr-xr-x 1 root root 916 Aug 15 16:34 /usr/lib/nagios/plugins/check_mailq*


#cat /usr/lib64/nagios/plugins/check_mailq

#!/bin/bash
#
# 19-07-2010
# Author: Cherwin Nooitmeer <cherwin@gmail.com>
#

# exit codes
e_ok=0
e_warning=1
e_critical=2
e_unknown=3



# regular expression that matches queue IDs (e.g. D71EF7AC80F8)
queue_id='^[A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9][A-F0-9]'

usage="Invalid command line usage"

if [ -z $1 ]; then
    echo $usage
    exit $e_unknown
fi

while getopts ":w:c:" options
do
    case $options in
        w ) warning=$OPTARG ;;
        c ) critical=$OPTARG ;;
        * ) echo $usage
            exit $e_unknown ;;
    esac
done

# determine queue size
qsize=$(mailq | egrep -c $queue_id)
if [ -z $qsize ]
then
    exit $e_unknown
fi

if [ $qsize -ge $critical ]; then
    retval=$e_critical
elif [ $qsize -ge $warning ]; then
    retval=$e_warning
elif [ $qsize -lt $warning ]; then
    retval=$e_ok
fi

echo "$qsize mail(s) in queue | mail_queue=$qsize"
exit $retval




===========@ In ICINGA server -===============
#no need to add nrpe user in sudoer file

# /usr/local/icinga/libexec/check_nrpe -H 5.9.240.227 -c check_mailq
 358 mail(s) in queue | mail_queue=358

ICINGA EXIM mailq script for icinga part 2

========================================================================
check mailq EXIM
 ========================================================================
At client side:-
#rpm -qf utils.pm                                  //tofind the package name of file
#yum install nagios-plugins-perl
do this if you face the"utils.sh not found error". make dir's as needed
#ln -s /usr/lib64/nagios/plugins/utils.sh  /usr/local/nagios/libexec/utils.sh
#visudo
   Comment out    

#Defaults    requiretty             <<<= = =

#add nrpe user like below line
root    ALL=(ALL)       ALL
nrpe ALL=NOPASSWD:/usr/sbin/exim                             
Save/exit
 ***************************************
copybelow script in file name  "check_eximmailqueue"
#ls -l  /usr/lib64/nagios/plugins/check_eximmailqueue
-rwxr-xr-x 1 root root   3285 Jul 27 06:25 check_eximmailqueue*
-rwxr-xr-x 1 root root 172880 Oct 17  2013 check_http*
-rwxr-xr-x 1 root root  40944 Oct 17  2013 check_load*
-rwxr-xr-x 1 root root  22256 Apr 30 21:28 check_nrpe*
-rwxr-xr-x 1 root root  36080 Oct 17  2013 check_users*
-rwxr-xr-x 1 root root  38696 Oct 17  2013 negate*
-rwxr-xr-x 1 root root  36104 Oct 17  2013 urlize*
-rw-r--r-- 1 root root   2091 Oct 17  2013 utils.pm
-rwxr-xr-x 1 root root   2728 Oct 17  2013 utils.sh*
cat /usr/lib64/nagios/plugins/check_eximmailqueue
#!/bin/sh
###############################################
#
# Nagios script to check Exim mail queue status
#
# Copyright 2007, 2008 Ian Yates
#
# NOTE: Depending on your config, the nagios user will probably be
#       needed to be added to the exim group for this script to function correctly
#
# See usage for command line switches
#

. /usr/local/nagios/libexec/utils.sh


VERSION="1.3"

EXIM=$(which exim)
SUDO=/usr/bin/sudo

FLAG_VERBOSE=FALSE
LEVEL_WARN=""
LEVEL_CRIT=""
RESULT=""
EXIT_STATUS=$STATE_OK


###############################################
#
## FUNCTIONS
#

## Print usage
usage() {
    echo " check_eximailqueue $VERSION - Nagios Exim mail queue check script"
    echo ""
    echo " Usage: check_eximailqueue -w <warning queue size> -c <critical queue size> [ -v ] [ -h ]"
    echo ""
    echo "         -w  Queue size at which a warning is triggered"
    echo "         -c  Queue size at which a critical is triggered"
    echo "         -v  Verbose output (ignored for now)"
    echo "         -h  Show this page"
    echo ""
}

## Process command line options
doopts() {
    if ( `test 0 -lt $#` )
    then
        while getopts w:c:vh myarg "$@"
        do
            case $myarg in
                h|\?)
                    usage
                    exit;;
                w)
                    LEVEL_WARN=$OPTARG;;
                c)
                    LEVEL_CRIT=$OPTARG;;
                v)
                    FLAG_VERBOSE=TRUE;;
                *)    # Default
                    usage
                    exit;;
            esac
        done
    else
        usage
        exit
    fi
}


# Write output and return result
theend() {
    echo $RESULT
    exit $EXIT_STATUS
}


#
## END FUNCTIONS
#

#############################################
#
## MAIN
#


# Handle command line options
doopts $@

# Do the do
OUTPUT=`$SUDO -u root $EXIM -bpc`
if test -z "$OUTPUT" ; then
    RESULT="Mailqueue WARNING - query returned no output!"
    EXIT_STATUS=$STATE_WARNING
else
    if test "$OUTPUT" -lt "$LEVEL_WARN" ; then
        RESULT="Mailqueue OK - $OUTPUT messages on queue"
        EXIT_STATUS=$STATE_OK
    else
        if test "$OUTPUT" -ge "$LEVEL_CRIT" ; then
            RESULT="Mailqueue CRITICAL - $OUTPUT messages on queue"
            EXIT_STATUS=$STATE_CRITICAL
        else
            if test "$OUTPUT" -ge "$LEVEL_WARN" ; then
                RESULT="Mailqueue WARNING - $OUTPUT messages on queue"
                EXIT_STATUS=$STATE_WARNING
            fi
        fi
    fi
fi

# Quit and return information and exit status
theend

delete file with inode

ls -il   #list file inode


stat  filename  

SYNTAX-  find . -inum [inode-number] -exec rm -i {} \;

Example:-
 
find . -inum 782263 -exec rm -i {} \;

(a) Create a hard to delete file name:
$ cd /tmp
$ touch "\+Xy \+\8"
$ ls

(b) Try to remove this file with rm command:
$ rm \+Xy \+\8

(c) Remove file by an inode number, but first find out the file inode number:
$ ls -ilOutput:
781956 drwx------  3 viv viv 4096 2006-01-27 15:05 gconfd-viv
781964 drwx------  2 viv viv 4096 2006-01-27 15:05 keyring-pKracm
782049 srwxr-xr-x  1 viv viv    0 2006-01-27 15:05 mapping-viv
781939 drwx------  2 viv viv 4096 2006-01-27 15:31 orbit-viv
781922 drwx------  2 viv viv 4096 2006-01-27 15:05 ssh-cnaOtj4013
781882 drwx------  2 viv viv 4096 2006-01-27 15:05 ssh-SsCkUW4013
782263 -rw-r--r--  1 viv viv    0 2006-01-27 15:49 \+Xy \+\8
Note: 782263 is inode number.
(d) Use find command to delete file by inode:
Find and remove file using find command, type the command as follows:
$ find . -inum 782263 -exec rm -i {} \;

python 2.6.6 mysqldb connect centos 6.3

yum groupinstall 'Development tools'
yum install python-setuptools
yum install unzip
yum install wget
yum install python-devel mysql-devel zlib-devel openssl-devel
wget --no-check-certificate https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.5.zip

unzip MySQL-python-1.2.5.zip

cd MySQL-python-1.2.5

[root@mail MySQL-python-1.2.5]# python setup.py build
running build
running build_py
copying MySQLdb/release.py -> build/lib.linux-i686-2.6/MySQLdb
running build_ext
[root@mail MySQL-python-1.2.5]# echo $?

[root@mail MySQL-python-1.2.5]# python setup.py install

.
.
.
Adding MySQL-python 1.2.5 to easy-install.pth file

Installed /usr/lib/python2.6/site-packages/MySQL_python-1.2.5-py2.6-linux-i686.egg
Processing dependencies for MySQL-python==1.2.5
Finished processing dependencies for MySQL-python==1.2.5

#echo $?
0

nmap command

#2: Scan multiple IP address or subnet (IPv4)

nmap 192.168.1.1 192.168.1.2 192.168.1.3
## works with same subnet i.e. 192.168.1.0/24
nmap 192.168.1.1,2,3
You can scan a range of IP address too:
nmap 192.168.1.1-20
You can scan a range of IP address using a wildcard:
nmap 192.168.1.*
Finally, you scan an entire subnet:
nmap 192.168.1.0/24
 

#3: Read list of hosts/networks from a file (IPv4)

nmap -iL /tmp/test.txt
 
cat > /tmp/test.txt
 
server1.cyberciti.biz
192.168.1.0/24
192.168.1.1/24
10.1.2.3
localhost
 

#4: Excluding hosts/networks (IPv4)

When scanning a large number of hosts/networks you can exclude hosts from a scan:
nmap 192.168.1.0/24 --exclude 192.168.1.5
nmap 192.168.1.0/24 --exclude 192.168.1.5,192.168.1.254

OR exclude list from a file called /tmp/exclude.txt
 
nmap -iL /tmp/scanlist.txt --excludefile /tmp/exclude.txt
 

#5: Turn on OS and version detection scanning script (IPv4)

nmap -A 192.168.1.254 nmap -v -A 192.168.1.1 nmap -A -iL /tmp/scanlist.txt

#6: Find out if a host/network is protected by a firewall

nmap -sA 192.168.1.254 nmap -sA server1.cyberciti.biz

#7: Scan a host when protected by the firewall

nmap -PN 192.168.1.1 nmap -PN server1.cyberciti.biz

#8: Scan an IPv6 host/address

The -6 option enable IPv6 scanning. The syntax is:
nmap -6 IPv6-Address-Here nmap -6 server1.cyberciti.biz nmap -6 2607:f0d0:1002:51::4 nmap -v A -6 2607:f0d0:1002:51::4

#9: Scan a network and find out which servers and devices are up and running

This is known as host discovery or    ping scan:      
nmap -sP 192.168.1.0/24

#10: How do I perform a fast scan?

nmap -F 192.168.1.1

#11: Display the reason a port is in a particular state

nmap --reason 192.168.1.1
nmap --reason server1.cyberciti.biz

#12: Only show open (or possibly open) ports

nmap --open 192.168.1.1
nmap --open server1.cyberciti.biz

#13: Show all packets sent and received

nmap --packet-trace 192.168.1.1
nmap --packet-trace server1.cyberciti.biz
 

#12: Only show open (or possibly open) ports

nmap --open 192.168.1.1 nmap --open server1.cyberciti.biz

#13: Show all packets sent and received

nmap --packet-trace 192.168.1.1
nmap --packet-trace server1.cyberciti.biz
 

14#: Show host interfaces and routes

This is useful for debugging (ip command or route command or netstat command like output using nmap)
nmap --iflist

#15: scan specific ports?

## Scan port 80
nmap -p 80 192.168.1.1
 
## Scan TCP port 80
nmap -p T:80 192.168.1.1
 
## Scan UDP port 53
nmap -p U:53 192.168.1.1
 
## Scan two ports ##
nmap -p 80,443 192.168.1.1
 
## Scan port ranges ##
nmap -p 80-200 192.168.1.1
 
## Combine all options ##
nmap -p U:53,111,137,T:21-25,80,139,8080 192.168.1.1
nmap -p U:53,111,137,T:21-25,80,139,8080 server1.cyberciti.biz
nmap -v -sU -sT -p U:53,111,137,T:21-25,80,139,8080 192.168.1.254
 
## Scan all ports with * wildcard ##
nmap -p "*" 192.168.1.1
 
## Scan top ports i.e. scan $number most common ports ##
nmap --top-ports 5 192.168.1.1
nmap --top-ports 10 192.168.1.1
 

#16: The fastest way to scan all your devices/computers for open ports ever

nmap -T5 192.168.1.0/24

#17: How do I detect remote operating system?

You can identify a remote host apps and OS using the -O option:
 
nmap -O 192.168.1.1
nmap -O  --osscan-guess 192.168.1.1
nmap -v -O --osscan-guess 192.168.1.1
 

#18: How do I detect remote services (server / daemon) version numbers?

nmap -sV 192.168.1.1

#19: Scan a host using TCP ACK (PA) and TCP Syn (PS) ping

If firewall is blocking standard ICMP pings, try the following host discovery methods:
nmap -PS 192.168.1.1
nmap -PS 80,21,443 192.168.1.1
nmap -PA 192.168.1.1
nmap -PA 80,21,200-512 192.168.1.1
 

#20: Scan a host using IP protocol ping

nmap -PO 192.168.1.1

#21: Scan a host using UDP ping

This scan bypasses firewalls and filters that only screen TCP:
nmap -PU 192.168.1.1 nmap -PU 2000.2001 192.168.1.1

#22: Find out the most commonly used TCP ports using TCP SYN Scan

  ### Stealthy scan ### nmap -sS 192.168.1.1   ### Find out the most commonly used TCP ports using TCP connect scan (warning: no stealth scan) ### OS Fingerprinting ### nmap -sT 192.168.1.1   ### Find out the most commonly used TCP ports using TCP ACK scan nmap -sA 192.168.1.1   ### Find out the most commonly used TCP ports using TCP Window scan nmap -sW 192.168.1.1   ### Find out the most commonly used TCP ports using TCP Maimon scan nmap -sM 192.168.1.1 
 

#23: Scan a host for UDP services (UDP scan)

Most popular services on the Internet run over the TCP protocol. DNS, SNMP, and DHCP are three of the most common UDP services. Use the following syntax to find out UDP services:
nmap -sU nas03
nmap -sU 192.168.1.1

#24: Scan for IP protocol

This type of scan allows you to determine which IP protocols (TCP, ICMP, IGMP, etc.) are supported by target machines:
nmap -sO 192.168.1.1

#25: Scan a firewall for security weakness

The following scan types exploit a subtle loophole in the TCP and good for testing security of common attacks:
 
## TCP Null Scan to fool a firewall to generate a response ##
## Does not set any bits (TCP flag header is 0) ##
nmap -sN 192.168.1.254
 
## TCP Fin scan to check firewall ##
## Sets just the TCP FIN bit ##
nmap -sF 192.168.1.254
 
## TCP Xmas scan to check firewall ##
## Sets the FIN, PSH, and URG flags, lighting the packet up like a Christmas tree ##
nmap -sX 192.168.1.254

 

#26: Scan a firewall for packets fragments

The -f option causes the requested scan (including ping scans) to use tiny fragmented IP packets. The idea is to split up the TCP header over
several packets to make it harder for packet filters, intrusion detection systems, and other annoyances to detect what you are doing.
nmap -f 192.168.1.1
nmap -f fw2.nixcraft.net.in
nmap -f 15 fw2.nixcraft.net.in
## Set your own offset size with the --mtu option ##
nmap --mtu 32 192.168.1.1

#27: Cloak a scan with decoys

The -D option it appear to the remote host that the host(s) you specify as decoys are scanning the target network too. Thus their IDS might report 5-10 port scans from unique IP addresses, but they won't know which IP was scanning them and which were innocent decoys:
nmap -n -Ddecoy-ip1,decoy-ip2,your-own-ip,decoy-ip3,decoy-ip4 remote-host-ip nmap -n -D192.168.1.5,10.5.1.2,172.1.2.4,3.4.2.1 192.168.1.5

#28: Scan a firewall for MAC address spoofing

  ### Spoof your MAC address ## nmap --spoof-mac MAC-ADDRESS-HERE 192.168.1.1   ### Add other options ### nmap -v -sT -PN --spoof-mac MAC-ADDRESS-HERE 192.168.1.1     ### Use a random MAC address ### ### The number 0, means nmap chooses a completely random MAC address ### nmap -v -sT -PN --spoof-mac 0 192.168.1.1  

#29: How do I save output to a text file?

The syntax is:
nmap 192.168.1.1 > output.txt nmap -oN /path/to/filename 192.168.1.1 nmap -oN output.txt 192.168.1.1

setup spamassassin centos 6 for zpanel

First we need to install postgrey daemon.
Open a terminal window and enter:


Code:
yum install postgrey

OK. Service installed!

Now open /etc/init.d/postgrey with your favorite editor and find this line:

Code:
vi /etc/init.d/postgrey

# search for this line
Code:
options="--unix=/var/spool/postfix/postgrey/socket"

It means that process "postgrey" is using socket instead of tcp connection. Socket path is cruical for postfix to communicate with postgrey. CTRL (CMD) + C this path for later use!

We need to start the service and make sure, that the service will start automatically after reboot!

Code:
service post grey start
chkconfig postgrey on

The postfix config part…
With your favourite editor open /etc/postfix/main.cf

Code:
vi /etc/postfix/main.cf

… and find the

Code:
smtpd_recipient_restrictions =

it should look something like this:

Code:
smtpd_recipient_restrictions =
   permit_mynetworks,
   permit_sasl_authenticated,
   check_policy_service unix:/var/spool/postfix/postgrey/socket, ### Add this line. Double check the socket path!!!

Mine smtpd_recipient_restrictions block looks like this:

Code:
smtpd_recipient_restrictions =
        permit_mynetworks,
        permit_sasl_authenticated,
        check_policy_service unix:/var/spool/postfix/postgrey/socket,
        reject_invalid_hostname,
        reject_unauth_destination,
        reject_non_fqdn_sender,
        reject_non_fqdn_recipient,
        reject_unknown_recipient_domain,
        reject_unauth_pipelining,
        reject_unknown_sender_domain,
        reject_unknown_recipient_domain,

# SPAM/black list checks

        reject_rbl_client sbl-xbl.spamhaus.org,
#       reject_rbl_client multi.uribl.com, ### Too many requests - payable service
        reject_rbl_client dsn.rfc-ignorant.org,
        reject_rbl_client dul.dnsbl.sorbs.net,
        reject_rbl_client dnsbl.njabl.org,
        reject_rbl_client bl.spamcop.net,
#       reject_rbl_client dnsbl.sorbs.net, ### This one is blocking emails from yahoo
        reject_rbl_client cbl.abuseat.org,
        reject_rbl_client ix.dnsbl.manitu.net,
        reject_rbl_client combined.rbl.msrbl.net,
        reject_rbl_client rabl.nuclearelephant.com,
        permit

If you want to whitelist some clients/recipients open this two files with your editor of choice:

Code:
vi /etc/postfix/postgrey_whitelist_clients
vi /etc/postfix/postgrey_whitelist_recipients

For the last step all we have to do is to reload the Postfix configuration with:

Code:
service postfix reload

Just to be sure that Postfix and Postgrey are working together check the maillog with:

Code:
tail -f /var/log/maillog

… and find this line

Code:
Aug 28 17:33:59 hostname postgrey[20092]: action=greylist, reason=new, client_name=remote.mail.server, client_address=<remote IP address>, sender=<email@address>, recipient=<email@address>

Well done. You've just dramatically reduced the number of SPAM messages.

If you want to read more about Postgrey service, here is the link: http://projects.puremagic.com/greylisting/

Enjoy!
=================================================================
 SCRIPT TO INSTALL IN CENTOS

#!/bin/sh
#
# Script to install postgrey and spamassassin, tested on Centos 6.4 and ZPanel 10.1.0
#
if which postgrey >/dev/null; then
echo "postgrey already exist"
else
echo "Installing postgrey"
yum -y install postgrey
sed -i '/^smtpd_recipient_restrictions =/ s/$/ check_policy_service inet:127.0.0.1:60000,/' /etc/zpanel/configs/postfix/main.cf
sed -i 's/options=\"--unix=\/var\/spool\/postfix\/postgrey\/socket\"/options=\"--inet=127.0.0.1:60000 --delay=150\"/g' /etc/init.d/postgrey
service postgrey start
service postfix reload
chkconfig postgrey on
echo "postgrey installed"
fi
#
if which spamassassin >/dev/null; then
echo "spamassassin already exist"
else
echo "Installing spamassassin"
yum -y install spamassassin
echo -e "\n" > /etc/mail/spamassassin/local.cf
sed -i '1s/^/required_hits 5.0\n/' /etc/mail/spamassassin/local.cf
sed -i '2s/^/report_safe 0\n/' /etc/mail/spamassassin/local.cf
sed -i '3s/^/required_score 5\n/' /etc/mail/spamassassin/local.cf
sed -i '4s/^/rewrite_header Subject ***SPAM***\n/' /etc/mail/spamassassin/local.cf
groupadd spamd
useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd
chown spamd:spamd /var/log/spamassassin
sed -i '/^smtp        inet/ s/$/ -o content_filter=spamassassin/' /etc/zpanel/configs/postfix/master.cf
sed -i '/^smtp      inet/ s/$/ -o content_filter=spamassassin/' /etc/zpanel/configs/postfix/master.cf
sed -i '/^smtp    inet/ s/$/ -o content_filter=spamassassin/' /etc/zpanel/configs/postfix/master.cf
sed -i '/^smtp  inet/ s/$/ -o content_filter=spamassassin/' /etc/zpanel/configs/postfix/master.cf
echo -e "\nspamassassin unix - n n - - pipe flags=R user=spamd argv=/usr/bin/spamc -e /usr/sbin/sendmail.postfix -oi -f \${sender} \${recipient}\n" >> /etc/zpanel/configs/postfix/master.cf
/etc/init.d/postfix restart
/etc/init.d/spamassassin restart
echo "SpamAssassin installed, to test it send a mail from outside with the subject: XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X"
echo "Your first email will take about 150 seconds to arrive"
fi

setup spamassassin ubuntu 12.04 for zpanel

 http://forums.sentora.io/showthread.php?tid=22
Ubuntu :How to setup Spamassassin
How to setup Spamassassin

1: Use apt-get to install Spamassassin and spamc.
Code: (Select All)
apt-get install spamassassin spamc
Add Spamassassin user

2: First add the group spams:
Code: (Select All)
groupadd spamd

3: Then add the user spamd with the home irectory /var/log/spamassassin:
Code: (Select All)
useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd

4: then create the directory /var/log/spamassassin and change the ownership:
Code: (Select All)
mkdir /var/log/spamassassin
chown spamd:spamd /var/log/spamassassin

Setting Up Spamassassin
5: Open the spamassassin config file using:
Code: (Select All)
nano /etc/default/spamassassin

6: Setting up spamassassin
Code: (Select All)
Find ENABLED=0 and change to ENABLED=1
Find CRON=0 and change to CRON=1
Find OPTIONS and change the line to
OPTIONS="--create-prefs --max-children 2 --username spamd \ -H ${SAHOME} -s ${SAHOME}spamd.log"
save and exit

7: Now create a variable named SAHOME with the Spamassassin home directory:
Code: (Select All)
SAHOME="/var/log/spamassassin/"

8: start spamassassin
Code: (Select All)
service spamassassin start

Configuring Postfix

9: Open Postfix config file using:
Code: (Select All)
nano /etc/postfix/master.cf

10: Find the the line
Code: (Select All)
smtp    inet n     -     -     -     -     smtpd
add "-o content_filter=spamassassin" after smtpd

11 End of the file add:
Code: (Select All)
spamassassin unix - n n - - pipe user=spamd argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}

12: restart postfix
Code: (Select All)
service postfix restart

Configuring Spamassassin

13: Open the Spamassassin default rules file using:
Code: (Select All)
nano /etc/spamassassin/local.cf

14 : make rules
Code: (Select All)
change
#rewrite_header
Subject ***** SPAM ***** to
rewrite_header Subject [*** SPAM ***]
change required_score 5.0 to required_score 3.0
use_bayes from 0 to 1
bayes_auto_learn from 0 to 1

15: now restart spamassassin
Code: (Select All)
service spamassassin restart

Hardening wordpress website

Hardening WordPress Website
==================================================================
Vulnerabilities in WordPress
Like many modern software packages, WordPress is updated regularly to address new security issues that may arise. Improving software security is always an ongoing concern, and to that end you should always keep up to date with the latest version of WordPress. Older versions of WordPress are not maintained with security updates.

Passwords
Many potential vulnerabilities can be avoided with good security habits. A strong password is an important aspect of this.

The goal with your password is to make it hard for other people to guess and hard for a brute force attack to succeed. Many automatic password generators are available that can be used to create secure passwords.

Securing wp-admin
Adding server-side password protection (such as BasicAuth) to /wp-admin/ adds a second layer of protection around your blog's admin area, the login screen, and your files. This forces an attacker or bot to attack this second layer of protection instead of your actual admin files. Many WordPress attacks are carried out autonomously by malicious software bots. One of the application you can use is latch. For more information on this application you can visit https://latch.elevenpaths.com/, its not only for your WordPress website but can also be used for others too.

Make use of following plugins:
Bulletproof security --> to create strong .htaccess file
Anti-Malware --> to scan the malicious files in the domain
ip blacklist --> to blacklist the ip which tries to do brute force attack


Generate the salt from following link and paste it in wp-config.php file
http://api.wordpress.org/secret-key/1.1/salt/


Summarizing:
1. Making sure your WordPress installation has the latest updates
2. Minimizing the number of plugins you use (and deleting the ones you don’t)
3. Choosing passwords that are difficult to crack
4. Performing regular data backups
5. Protecting your WordPress using .htaccess


For more information please visit following links
http://codex.wordpress.org/Hardening_WordPress
http://www.firedaemon.com/blog/wordpress-hardening-guide
http://thematosoup.com/wordpress-security-htaccess/