Skip to content

Instantly share code, notes, and snippets.

@sprowell
Created December 12, 2019 03:57
Show Gist options
  • Select an option

  • Save sprowell/c3cf9d04f52f764caa8b38d52071fea4 to your computer and use it in GitHub Desktop.

Select an option

Save sprowell/c3cf9d04f52f764caa8b38d52071fea4 to your computer and use it in GitHub Desktop.

Revisions

  1. sprowell created this gist Dec 12, 2019.
    20 changes: 20 additions & 0 deletions notify-ssh-login.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #!/bin/bash

    PATH=/bin:/usr/bin:/usr/sbin
    SUBJ="Alert - Remote SSH access from ${PAM_USER}"

    if [ -z "$PAM_TYPE" -o "$PAM_TYPE" == "open_session" ]
    then

    sendmail alert <<END
    $(hostname) $(date): LOGIN by ${PAM_USER} from ${PAM_RHOST}
    $(who)
    END

    else

    sendmail alert <<END
    $(hostname) $(date): LOG OUT by ${PAM_USER} from ${PAM_RHOST}
    END

    fi