Created
April 27, 2023 17:37
-
-
Save adamz01h/09e210f95ee8bcc74c8c4756c7db56c9 to your computer and use it in GitHub Desktop.
send email on account login bash script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #install this in the /etc/profile.d/ to have it run on log in | |
| IP="$(who am i|awk '{ print $5}')" | |
| HOSTNAME=$(hostname) | |
| NOW=$(date +"%e %b %Y, %a %r") | |
| echo 'Someone from '$IP' logged into '$HOSTNAME' on '$NOW'.' | mail -s 'SSH Login Notification' <[email protected]> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nano /etc/profile.d/email_login.sh
sudo apt install mailutils