Get Debian Virtual Machine IP Pushbullet Notifications

PushBullet-iconVirtual machine test environments make practicing a guide or new configuration efficient and productive. I use VM Workstation, VM Player is the free version, for testing guides in a closed development environment. I like to SSH into the Debian virtual machines. Instead of clicking on the console in VM Player, I have scripted a Pushbullet notification which uses curl to send the IP of the virtual machine so I don't have to waste any time running ifconfig to get the Debian virtual machine's IP address.

I get the Pushbullet notification of the virtual machine IP address on my phone and in Chrome (Firefox extension is available too), Android and iOS (iPhones, iPads) which makes connecting to it in Putty a 1 step process instead of several steps. This guide will work for any Debian system (not only virtual systems) like Ubuntu, Raspberry Pi Raspbian, Bananian etc and therefore any virtualization software like Virtualbox and VMware Fusion,

Get Debian Virtual Machine IP Pushbullet Notifications

Install curl which is necessary for sending the Pushbullet notification

sudo apt-get install curl -y

Make sure this syntax returns the IP of your virtual machine

ifconfig eth0 | awk -F"[: ]+" '/inet addr:/ {print $4}'

If it doesn't you will have to adjust the field it is printing from awk, currently it is the fourth line ($4)

This command will help you identify the right line to strip the IP from

ifconfig eth0

Edit your rc.local file so the curl command is launched at the virtual machine boot sequence

sudo nano /etc/rc.local

Paste this in rc.local, change PushbulletAccessToken which you can get from your Pushbullet settings page and VM Name to something you can identify your virtual machine with.

showip=$(ifconfig eth0 | awk -F"[: ]+" '/inet addr:/ {print $4}')
curl -u PushbulletAccessToken: https://api.pushbullet.com/v2/pushes -d type=note -d title="VM Name" -d body=$showip
exit 0

Ctrl+X, Y and Enter to save and then reboot the virtual machine

If you discover you are not getting your Pushbullet notifications add a sleep of 5 or 10 seconds to rc.local

sleep 5
showip=$(ifconfig eth0 | awk -F"[: ]+" '/inet addr:/ {print $4}')
curl -u PushbulletAccessToken: https://api.pushbullet.com/v2/pushes -d type=note -d title="VM Name" -d body=$showip
exit 0

Now you will get Pushbullet notifications displaying the IP of your Debian virtual machine so you can easily SSH into it using your favorite SSH client.