#! /usr/bin/env sh [ "$PAM_TYPE" = "open_session" ] || exit 0 { echo "User: $PAM_USER" echo "Ruser: $PAM_RUSER" echo "Rhost: $PAM_RHOST" echo "Service: $PAM_SERVICE" echo "TTY: $PAM_TTY" echo "Date: `date`" echo "Server: `hostname -f`" } | mail -s "`hostname -s` $PAM_SERVICE login: $PAM_USER" root