Skip to content

Instantly share code, notes, and snippets.

@axeleroy
Last active Oct 2, 2019
Embed
What would you like to do?
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