Skip to content

Instantly share code, notes, and snippets.

@beevelop
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save beevelop/a11a5562e4b4ac300f6a to your computer and use it in GitHub Desktop.

Select an option

Save beevelop/a11a5562e4b4ac300f6a to your computer and use it in GitHub Desktop.

Revisions

  1. beevelop revised this gist Jun 27, 2015. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions sshnotify.sh
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,18 @@
    # SSH Login Notification for Pushover
    # Add to end of /etc/profile
    # Change priority to -1 to always send as a quiet notification
    # 1 to display as high-priority and bypass the user's quiet hours
    # 2 to also require confirmation from the user

    if [ -n "$SSH_CLIENT" ]; then
    TITLE="${USER}@$(hostname -f)"
    TEXT="$(date): SSH login to ${USER}@$(hostname -f)"
    TEXT="$TEXT from $(echo $SSH_CLIENT|awk '{print $1}')"

    curl -s \
    -F "token=API-TOKEN" \
    -F "user=API-USER" \
    -F "title=$TITLE" \
    -F "message=$TEXT" \
    -F "priority=1" \
    -F "priority=2" \
    -F "retry=342" \
    -F "expire=7042" \
    https://api.pushover.net/1/messages.json >/dev/null 2>&1
    fi
  2. JT renamed this gist Aug 4, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. JT created this gist Mar 27, 2014.
    17 changes: 17 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    # SSH Login Notification for Pushover
    # Add to end of /etc/profile
    # Change priority to -1 to always send as a quiet notification
    # 1 to display as high-priority and bypass the user's quiet hours
    # 2 to also require confirmation from the user

    if [ -n "$SSH_CLIENT" ]; then
    TEXT="$(date): SSH login to ${USER}@$(hostname -f)"
    TEXT="$TEXT from $(echo $SSH_CLIENT|awk '{print $1}')"

    curl -s \
    -F "token=API-TOKEN" \
    -F "user=API-USER" \
    -F "message=$TEXT" \
    -F "priority=1" \
    https://api.pushover.net/1/messages.json >/dev/null 2>&1
    fi