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.
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
You can find the NodeCode at the following link:
„Auslöser“ konfigurieren
Damit Euer RaspberryPi auch einen „Auslöser“ an NodeRed sendet sobald sich jemand einloggt, müsst Ihr nun noch die folgenden Einstellungen konfigurieren.
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
Speichert die Datei dann ab indem Ihr STRG+X drückt und mit „Y“ und „Enter“ bestätigt.
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. 🙂
can´t get work on raspberry pi 4 with bullseyes,node-red v 2.2.2 ,how can i check ???
Hi,
can you give me some more details about what is not working?
Best regards
Fab
Unfortunately it doesn't work with a Pi 4 and NodeRed V3.1.3
Hi Anderle,
Can you give me some information about what exactly isn't working? Then I can help you too. 🙂
Best regards
Fabian