Send a Text Message anytime someone logs in to your Linux server

  • 0

Send a Text Message anytime someone logs in to your Linux server

Want to receive a text message every time someone logs via SSH into a linux server (or desktop)? Fortunately there is a free web based API provided by textbelt.com that can do just that:

Create a file in /etc/profile.d

$ sudo nano /etc/profile.d/notifybytxt.sh

Enter the following 2 lines (be sure to change the phone number to match the one you want to receive the text messages)

#!/bin/bash
curl http://textbelt.com/text -d number=5055551212 -d “message=login by user: $USER@$HOSTNAME from ${SSH_CLIENT%% *} at $(date +”%m-%d-%Y %r”)” > /dev/null 2>&1

Make it executable

$ sudo chmod +x /etc/profile.d/notifybytxt.sh

Log off and back on to test.