Love To :- Mom and Dad
Specail thanks to :- DeadManIndia,Null_Port_Govind
Lets start its not a big deal we are using some code of bash scripting and easily take a main on our mail addresss when anybody login in our server and open terminal or take access threw ssh.
Setups :)
1 Open the file threw vim editor or other editor i m using gedit in my case
file path :- /etc/bashrc
2 the at end of the file paste this code and save
rootalert() {
echo 'ALERT - Root Shell Login'
echo
echo 'Server: '`hostname`
echo 'Time: '`date`
echo 'User: '`who | awk '{ print $1 }'`
echo 'TTY: '`who | awk '{ print $2 }'`
echo 'Source: '`who | awk '{ print $6 }' | /bin/cut -d '(' -f 2 | /bin/cut -d ')' -f 1`
echo
echo
echo 'This email is send by Mr.Deeak saini system :P.'
}
rootalert | mail -s "Alert: Root Login [`hostname`]" youremaiid@gmail.com
And save the file and then access the ssh threw putty or other client then you check the mail in spam and your work is done.
Proff when my friend DeadManIndia access my redhat system then i got mail.
Thanks for reading
Jai-Hind Jai Bharat
2 comments:
we will try our best
Post a Comment