Email alerts whenever someone logs into root via SSH

If you’d like to be notified by email every time someone logs into your server via ssh do the following

Go to the /root directory and edit .bashrc

Towards the bottom of the file add the following

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

Change (YourServerName) for the name you’d like to identify your server
Change you@yourdomain.com to the email address you want the notification to go to

Print Friendly, PDF & Email

More Like This


Categories


Linux Security
  • Post a comment