Problem in send email notification for ssh root login


#1

i have an ubuntu 12.04. i install bsd-mailx in my ubuntu and have internet on my server. I set the alarm to send me an email, when who login to server with root user.

configurtion that send email notification to me is as follows. i add this cod in .bashrc file in root directory.

echo 'ALERT - Root Shell Access (underzero) on:'datewho| mail -s "Alert: Root Access fromwho | cut -d’(’ -f2 | cut -d’)’ -f1" undrezero@myemail.com

but i whene login with root user, email notification alarm, don’t send to my email.

pleas help me.


#2

Hi

Are you able to send mail from your linux box to your mail, did you configured you mail server, once look at the below link


#3

I use a script for this problem but acctually there is a application in server which automatically creates one directory and one file and after some hours it delets that file and folder and recreates them again.
What do i do, if i want to ignore ‘licence.php’ and ‘update’ directory in my script so the script doesn’t email their names (the file and folder name)

#!/bin/bash

inotifywait -mqr -e create,moved_to /usr/share/nginx/html/ | while read path action file; do

        if [ "$file" != "licence.php" ] &&  [ "$file" != "update" ]; then


       echo "The file '$file' appeared in directory '$path' via '$action'" | mailx -s "File ${NEWFILE} has been created" "mail@xxxxx.com"

        fi
         done

Acctually my script will email me file and folders which are made but it doesn’t ignore licence.php and update folder , ignore part in my script doesn’t work and even with creation of these 2 file and folder , script will continue its work and email me their names too.
How can i solve this problem?