Skip to content

Instantly share code, notes, and snippets.

@davenicoll
Last active January 29, 2021 22:14
Show Gist options
  • Save davenicoll/6870dedffe75877701bd5bb0eaa5f15d to your computer and use it in GitHub Desktop.
Save davenicoll/6870dedffe75877701bd5bb0eaa5f15d to your computer and use it in GitHub Desktop.
#!/bin/bash
if [[ -z "$SSH_CLIENT" ]]; then SSH_CLIENT="127.0.0.1"; fi
TEXT="A user successfully logged on to \`$USER@$HOSTNAME\` ($(hostname -I | awk '{print $1}')) from \`$(echo $SSH_CLIENT | awk '{print $1}')\`.<br/>Please review this activity."
MESSAGE=$( echo ${TEXT} | sed 's/"/\"/g' | sed "s/'/\'/g" )
JSON="{\"title\": \"Unusual user login activity\", \"themeColor\": \"\", \"text\": \"${MESSAGE}\" }"
curl --silent -H "Content-Type: application/json" -d "${JSON}" "https://outlook.office.com/webhook/..." > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment