Tuesday, 8 July 2014

How to set the mail notifier on ssh in Red Hat Linux

Jai-Hind TO all I am Deepak Saini Here again and make an intersting tut on ssh may be it helpfull for you speacially hackers.IHT_LAB pe Rh ke hum bhi kuch shik jayege :)

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  :)
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:

This comment has been removed by the author.

Post a Comment