HowTo: Node Red – Pushbullet notification for SSH login

With the FritzBox I am used to being notified as soon as someone logs into my FritzBox. I think this is a great safety feature.

At some point I thought that it would be nice if this feature was also available for the RaspberryPi. So I put together the solution below.

When a login is recognized on my NodeRed server (the RaspberryPi), this sends me a message via Pushbullet.

In the article you will find everything you need to create your own NodeRed SSH login notification.


Safety instructions

I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.
https://www.nerdiy.de/sicherheitshinweise/

Affiliate links/advertising links

The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and make a purchase via this link, Nerdiy.de will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support Nerdiy.de in being able to offer other useful projects in the future. 🙂 


Requirements

Helpful articles:
So that you can install new nodes, NodeRed should of course already be installed.
How to prepare a RaspberryPi and then install NodeRed on it is described in the following articles.

The following three articles describe what needs to be done to prepare the RaspberryPi:
RaspberryPi – setup for nerdiys!
RaspberryPi – The first configuration!
RaspberryPi – Control the RaspberryPi via SSH

NodeRed – Installing NodeRed on the RaspberryPi
NodeRed - import and export node code

Required tool:
-no-

Required material:

In the following list you will find all the parts you need to implement this article.


Log into the NodeRed configuration interface

Before you can edit your NodeRed configuration, you must - if activated - first log into the NodeRed configuration interface.

View of the login dialog. Here you have to enter the login data that you specified during the configuration of the login. You can find information about this in the article NodeRed - set up user login.

Insert NodeCode

The NodeCode below contains everything necessary to evaluate a received notification and forward it to you via Pushbullet. How you can insert NodeCode into your NodeRed configuration is in the article NodeRed - import and export node code described.

Of course, in order for Pushbullet to forward the notification to you, you need to configure the Pushbullet Node accordingly. You can find tips on how to do this in the article NodeRed - Send pushbullet messages on events

View of the configuration in the NodeRed configuration interface. You may still need to configure the Pushbullet node (here labeled “KlugesHaus”) accordingly.

You can find the NodeCode at the following link:

https://github.com/Nerdiyde/NodeRedSnippets/blob/master/snippets/pushbullet_notification_at_ssh_login.json


Configure “Triggers”.

So that your RaspberryPi also sends a “trigger” to NodeRed as soon as someone logs in, you now have to configure the following settings.

To do this, switch to the console of your RaspberryPi and open your .bashrc with the following command.

sudo nano /home/pi/.profile

If you are logged in with a different user name, you will of course have to adapt the command.

In the file that is now open you have to use the arrow keys to...

…navigate to the end of the file.

Then insert the following code there.

#SSH login notification to nodeRed by Nerdiy.de LOGIN_USER="$( whoami )" LOGIN_DATE="$( date +%s )" LOGIN_HOSTNAME="$( hostname)" curl -Isk 'https://localhost:1880/ssh_login.json ?user='$LOGIN_USER'&date='$LOGIN_DATE'&host='$LOGIN_HOSTNAME >> /dev/null

Then save the file by pressing CTRL+X and confirming with “Y” and “Enter”.

If you log in to your RaspberryPi again via SSH, you should be notified via a Pushbullet message.

Of course, you can also trigger other actions (email, lamp flashing, etc.). Thanks to NodeRed, everything can be configured as desired. 🙂


Have fun with the project

I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂

PS Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂

Buy Me a Coffee at ko-fi.com       

4 comments

    1. Hi Anderle,
      Can you give me some information about what exactly isn't working? Then I can help you too. 🙂
      Best regards
      Fabian

Kommentar hinterlassen

Your email address will not be published. Erforderliche Felder sind mit * markiert

This site uses Akismet to reduce spam. Learn how your comment data is processed.