Skip to content

Instantly share code, notes, and snippets.

@D4R4
Last active March 4, 2022 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save D4R4/1d1bfbb0dde320c229d6fcfcf0f74632 to your computer and use it in GitHub Desktop.
Save D4R4/1d1bfbb0dde320c229d6fcfcf0f74632 to your computer and use it in GitHub Desktop.
Send email on ssh sessions, useful to put in .bashrc, Requires sendemail package to be installed
UZR=`who | cut -d"(" -f2 | cut -d")" -f1`
if [ "$UZR" != "" ]; then
sendemail -f 'noreply@dest.com' -t 'dest@dest.com' -s '10.10.10.10' -u "Alert: Root Access on `hostname` from $UZR" -m "at `date`" > /dev/null 2>&1
sendemail -f 'noreply@dest.com' -t 'dest@dest.com' -s '10.10.10.10' -u "Alert: Root Access on `hostname` from $UZR" -m "at `date`" > /dev/null 2>&1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment