Root Login E-Mail alert

In order for a root login with an email you have to enable the following to obtain Alert:

1. E-mail service on the server enable
2. /root / .bashrc adapt

(1) Email Server

apt-get install postfix

General type of mail configuration: <– Website
System mail name: <– server1.example.com
Root and postmaster mail recipient: <– [blank]
Other destinations to accept mail for (blank for none): <– server1.example.com, localhost.example.com, localhost.localdomain, localhost
Force synchronous updates on mail queue? <– No
Local networks: <– 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
Use procmail for local delivery? <– Yes
Mailbox size limit (bytes): <– 0
Local address extension character: <– +
Internet protocols to use: <– all

(2) /root/.bashrc
one opens with an editor and add the following line /root/.bashrc

echo ‘ALERT – Root Shell Access (“servername”) on:’ `date` `who` | mail -s “Alert: “servername”- Root Access from `who | cut -d”(” -f2 | cut -d”)” -f1`” “e-mail address”

Then you have to save all and you get at each root / sudo login email