🇧🇬 Български | 🇬🇧 English
Bash script for monitoring SSH activity on Unraid servers with push notifications via ntfy.sh.
This script monitors SSH logs in real-time and sends notifications for:
- ✅ Successful SSH login
- ❌ Failed login attempt
- 🚪 SSH logout
Notifications include username and IP address information.
Simple script with ntfy.sh support for public topics.
Enhanced version with additional features:
- 🔐 Token authentication for private ntfy.sh topics
- 🌍 Country detection with flag emojis (via ipapi.co)
- 📱 Telegram support (optional)
- 🎯 Better user extraction for various SSH log formats
- 🔒 Custom ntfy.sh server support
- Real-time monitoring - Uses
tail -Ffor continuous syslog monitoring - Smart deduplication - Prevents notification spam (5 sec for failed attempts, 30 sec for others)
- Prioritization - Different priority levels based on event type
- Easy setup - Only one parameter to configure
- Country detection - Shows country name and flag emoji for each IP
- Token authentication - Secure access to private ntfy topics
- Telegram integration - Dual notifications (ntfy + Telegram)
- Custom server - Use your own ntfy.sh instance
- Enhanced logging - Better event detection and user extraction
wget https://raw.githubusercontent.com/zantag/USA/main/unraid-ssh-alert.sh
chmod +x unraid-ssh-alert.shEdit the script and change NTFY_TOPIC:
nano unraid-ssh-alert.shFind the line:
NTFY_TOPIC="put-your-ntfy-topic"And replace it with your ntfy.sh topic (e.g., my-unraid-alerts).
./unraid-ssh-alert.shOpen a new SSH session to the server - you should receive a notification.
wget https://raw.githubusercontent.com/zantag/USA/main/unraid-ssh-alert-token-auth.sh
chmod +x unraid-ssh-alert-token-auth.shEdit the script:
nano unraid-ssh-alert-token-auth.shConfigure the following variables:
# NTFY Configuration
NTFY_TOPIC="your-topic" # Your ntfy.sh topic
NTFY_SERVER="https://ntfy.sh" # Or your own server
NTFY_TOKEN="" # Optional: leave empty for public topics
# Telegram Configuration (optional)
TELEGRAM_BOT_TOKEN="" # Your Telegram Bot Token
TELEGRAM_CHAT_ID="" # Your Telegram Chat ID./unraid-ssh-alert-token-auth.shOpen a new SSH session - you should receive notifications via ntfy (and Telegram if configured).
- Install User Scripts plugin from Community Applications
- Create a new script
- Copy the contents of
unraid-ssh-alert.sh - Set it to run At Startup of Array
Add to /boot/config/go:
/path/to/unraid-ssh-alert.sh &-
Install the ntfy app on your phone:
-
Subscribe to your topic (same as in
NTFY_TOPIC) -
(Optional) For private topics, create an access token at ntfy.sh
-
Done! You'll receive notifications for SSH activity
-
Create a Telegram bot:
- Message @BotFather on Telegram
- Send
/newbotand follow instructions - Copy the Bot Token
-
Get your Chat ID:
- Message @userinfobot
- Copy your Chat ID
-
Add both values to the script configuration
- The script runs locally and doesn't send sensitive information
- Uses the public ntfy.sh server (or you can host your own)
- For additional security, check out ntfy authentication
- Unraid 6.x or newer
curl(pre-installed on Unraid)- Internet connection for ntfy.sh notifications
-
Check if the script is running:
ps aux | grep unraid-ssh-alert -
Test ntfy.sh manually:
curl -d "Test message" https://ntfy.sh/your-topic -
Check the logs:
tail -f /var/log/syslog | grep sshd
The script has built-in deduplication. If you're still receiving too many, you can increase the DUP_TIME values in the script.
MIT License - free to use and modify
Pull requests are welcome! For major changes, please open an issue first to discuss.
zantag
⭐ If this script is useful to you, leave a star on the repo!