Skip to content

Instantly share code, notes, and snippets.

@adamz01h
Created April 27, 2023 17:37
Show Gist options
  • Select an option

  • Save adamz01h/09e210f95ee8bcc74c8c4756c7db56c9 to your computer and use it in GitHub Desktop.

Select an option

Save adamz01h/09e210f95ee8bcc74c8c4756c7db56c9 to your computer and use it in GitHub Desktop.
send email on account login bash script
#!/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]>
@adamz01h
Copy link
Author

adamz01h commented Apr 27, 2023

nano /etc/profile.d/email_login.sh

sudo apt install mailutils

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment