Last active
October 2, 2019 20:12
-
-
Save axeleroy/e23e418329f305419351ec3b1cb5ded4 to your computer and use it in GitHub Desktop.
Send Pushbullet notification on SSH connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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