provisioning tool for building opinionated architecture
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
572 B

10 months ago
  1. #!/bin/bash
  2. [[ "$PAM_TYPE" != "open_session" ]] && exit 0
  3. if journalctl --since "1 minute ago" -u ssh | tac | grep Accepted -m1 | grep password; then
  4. {
  5. echo "User: $PAM_USER"
  6. echo "Remote Host: $PAM_RHOST"
  7. echo "Service: $PAM_SERVICE"
  8. echo "TTY: $PAM_TTY"
  9. echo "Date: $(date)"
  10. echo "Server: $(uname -a)"
  11. echo
  12. echo "Somebody has successfully logged in your machine, please be aware and acknowledge this event."
  13. } | mail -s "$PAM_SERVICE login on $(hostname -f) for account $PAM_USER" root
  14. fi
  15. exit 0