SSH Login Notifications using Pushbullet

Pushbullet is a great app that allows you to share notifications to and from your phone/computer. I recently saw Dead Man’s Snitch (a service which alerts you about cron jobs) and figured I could probably replicate the most important functionality for me using Pushbullet. After all, being a poor student is all about saving as much money as possible!

Playing around with the Pushbullet API whilst setting up backup notifications for my servers, I wondered if I could get a push notification every time (hopefully) just me logged in via SSH.

I ended up with the following bash script that can be added to your bash login script (~/.bash_profile)

1
2
3
4
5
#!/bin/bash
IP=($SSH_CLIENT)
name=$(whoami)
string="SSH Login from $IP for $name"
/home/admin/pushbullet/pushbullet push all note "$string"

It uses this library from Github, but could do it without the library at all if you’re not as lazy as I am. More Pushbullet goodness soon!

pushbullet

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s