User Tools

Site Tools


blog:send_email_on_root_login

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
blog:send_email_on_root_login [2009-07-02 06:52] – created brbblog:send_email_on_root_login [2009-07-02 07:09] (current) brb
Line 4: Line 4:
  
 Login as root and edit the file, ‘~/.bash_profile’. Near the bottom add this: Login as root and edit the file, ‘~/.bash_profile’. Near the bottom add this:
-  echo -e “Subject: Root Access\n\nALERT – Root Shell Access on: `date`, `who`\n” | ssmtp user@domain.com+  echo -e “Subject: Root Access\n\nALERT – Root Shell Access on: `date`, `who`\n” | mail -s "Root access" user@domain.com
  
 Now to test it, log out of root and then log back on as root. You should now get an alert that someone has logged in as root. This script shows the time and user. You can adjust the information accordingly depending on how detailed you want it. Now to test it, log out of root and then log back on as root. You should now get an alert that someone has logged in as root. This script shows the time and user. You can adjust the information accordingly depending on how detailed you want it.
Line 10: Line 10:
 Example: Example:
  
- ALERT - Root Shell Access on: Tue Jun 30 20:06:40 MDT 2009, +  ALERT - Root Shell Access on: Tue Jun 30 20:06:40 MDT 2009, 
- nixtutor     pts/       2009-06-30 19:47 (NixTutor)+  nixtutor     pts/       2009-06-30 19:47 (NixTutor)
  
 Source: http://www.nixtutor.com/linux/the-benefits-of-setting-up-ssmtp-or-any-email-server/ Source: http://www.nixtutor.com/linux/the-benefits-of-setting-up-ssmtp-or-any-email-server/
blog/send_email_on_root_login.1246510361.txt.gz · Last modified: 2009-07-02 06:52 by brb