Skip to content

Instantly share code, notes, and snippets.

@wkettler
Last active February 1, 2019 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wkettler/fb60d75c7962a891f2eb59bfa0e61c0d to your computer and use it in GitHub Desktop.
Save wkettler/fb60d75c7962a891f2eb59bfa0e61c0d to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ "$PAM_TYPE" == "close_session" ]; then
exit
fi
curl -s -X POST -H 'Content-type: application/json' SLACK_WEBHOOK \
-d @- > /dev/null << EOF
{
"attachments": [
{
"fallback": "Login - $HOSTNAME.",
"title": "$HOSTNAME",
"text": "New login!",
"fields": [
{
"title": "User",
"value": "$PAM_USER",
"short": true
},
{
"title": "IP",
"value": "$PAM_RHOST",
"short": true
}
],
"color": "warning"
}
]
}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment