Use cases

Get an SMS when someone logs in to your server

This immediate alert adds an extra layer of security by enabling quick detection and response to unauthorized logins. Perfect for IT administrators and companies aiming to maintain a high security standard for their systems

Receive an SMS notification every time someone logs into your server. This immediate alert adds an extra layer of security by enabling quick detection and response to unauthorized logins. Perfect for IT administrators and companies aiming to maintain a high security standard for their systems. This feature is also ideal for monitoring your home lab, giving you peace of mind by keeping you informed about all login activities.

To quickly set this up, first create a simple script to send the SMS. Below is an example we use ourselves.

#!/usr/bin/python3

import requests

# Your 46elks API credentials
api_username = '###'
api_password = '###'

sms_recipient = '###'   # The number to receive notifications
sms_sender = 'HomeLAB'  # Or an approved phone number

def send_sms_via_46elks():
    message = "Login detected on HomeLAB"
    response = requests.post('https://api.46elks.com/a1/SMS', auth=(api_username, api_password), data={
        'from': sms_sender,
        'to': sms_recipient,
        'message': message,
    })

    if response.status_code == 200:
        print("SMS sent!")
    else:
        print(f"Failed to send SMS: {response.text}")

if __name__ == "__main__":
    send_sms_via_46elks()

Save it, for example, as /usr/local/bin/login-notify.py.

Then make the script executable:

chmod +x /usr/local/bin/login-notify.py

If you want the script to run for all users who log in, you can add the command to /etc/profile. This file runs for all users logging in through an interactive shell session.

Open /etc/profile in a text editor:

sudo nano /etc/profile

Add the following line:

/usr/local/bin/login-notify.py

Save and close the file.

Done! Now you will receive an SMS every time someone logs into your server, hopefully helping you sleep better at night πŸ™‚