Skip to content

Instantly share code, notes, and snippets.

@axeleroy
Last active October 2, 2019 20:12
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 axeleroy/e23e418329f305419351ec3b1cb5ded4 to your computer and use it in GitHub Desktop.
Save axeleroy/e23e418329f305419351ec3b1cb5ded4 to your computer and use it in GitHub Desktop.
Send Pushbullet notification on SSH connection
#!/bin/bash
access_token=<pushbullet access token> # Get it from your account settings page (https://www.pushbullet.com/#settings/account)
# Get IP, reverse DNS and hostname
ip=${SSH_CONNECTION%% *}
reverse=$(dig -x $ip +short)
hostname=$(hostname)
curl --request POST \
--url https://api.pushbullet.com/v2/pushes \
--header "Access-Token: $access_token" \
--header 'Cache-Control: no-cache' \
--header 'Content-Type: application/json' \
--data "{\"title\": \"New connection on $host\", \"body\": \"$USER connected from $ip ($reverse)\", \"type\": \"note\" }" \
> /dev/null 2>&1 # Redirecting the outputs to make the script silent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment