Sudo can be configured to to send e-mail when the sudo command is used.
Edit /etc/sudoers file:
mailto "me@example.com"
mail_always on
* mailto “me@example.com” : Admin email Address.
* mail_always : Send mail to the mailto user every time a users runs sudo.
Additional options:
| Option | Description |
|---|---|
| mail_badpass | Send mail to the mailto user if the user running sudo does not enter the correct password. This flag is off by default. |
| mail_no_host | If set, mail will be sent to the mailto user if the invoking user exists in the sudoers file, but is not allowed to run commands on the current host. This flag is off by default. |
| mail_no_perms | If set, mail will be sent to the mailto user if the invoking user is allowed to use sudo but the command they are trying is not listed in their sudoers file entry or is explicitly denied. This flag is off by default. |
| mail_no_user | If set, mail will be sent to the mailto user if the invoking user is not in the sudoers file. This flag is on by default. |