Monday, March 28, 2011

Use Gmail Account To Relay Email From a Shell Prompt

yum install ssmtp

vi /etc/ssmtp/ssmtp.conf
AuthUser=username@gmail.com
AuthPass=Your-Gmail-Password
FromLineOverride=YES
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES
:wq!
make sure sendmail is disabled
# service sendmail stop

# chkconfig sendmail off

# mkdir /bakup

# mv /usr/sbin/sendmail /bakup

#  ln -s /usr/sbin/ssmtp /usr/sbin/sendmail

  echo "This is a test" | mail -s "Test" user@domain.com

#######################################################


to get alerts when root logins

add the followings in .bash_profiles in the root home

vi .bash_profile

echo 'ALERT - Root Shell Access on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" user@domain.com


:wq! 

1 comment:

retheesh said...

Very nice article... Should help a lot in regular usage