Log Analyzer is a Bash-based tool for monitoring and analyzing SSH login attempts on Linux servers.
It detects brute-force attempts by checking failed SSH login entries in /var/log/auth.log and can automatically block suspicious IPs using UFW or iptables.
Optionally, it can send Telegram alerts when a brute-force attack is detected.
- Detects repeated failed SSH login attempts
- Counts frequency of suspicious IP addresses
- Blocks malicious IPs using:
- UFW (Uncomplicated Firewall)
- iptables
- Sends real-time notifications via Telegram (optional)
- Stores analysis logs in the
logs/directory - Fully configurable via
config.conf
Before running the script, make sure you have:
- A Linux server (Debian/Ubuntu recommended)
- Bash shell
curlinstalled- Either ufw or iptables installed and active
- Optional: Telegram bot for receiving alerts
git clone https://github.com/YOUR_USERNAME/log-analyzer.git
cd log-analyzerOpen config.conf and set your preferences:
nano config.confYou can configure:
- LOG_FILE → SSH authentication log path
- THRESHOLD → number of failed attempts before blocking
- FIREWALL → choose ufw or iptables
- OUTPUT_LOG → output log file
- Optional Telegram settings:
- TELEGRAM_TOKEN
- TELEGRAM_CHAT_ID
Ensure curl, iptables, or ufw are installed and active on the server.
Run the Analyzer
bash log-analyzer.sh- Create a Telegram bot
- Open Telegram
- Search for BotFather
- Send /newbot
- Choose a bot name + username
- Copy the bot token shown by BotFather:
1234567890:ABCDEF-YourTokenHere
Place it inside config.conf:
TELEGRAM_TOKEN="your-bot-token"
- Find your Telegram Chat ID
- Send a message (like /start) to your new bot
- Run this command on your server:
curl -s "https://api.telegram.org/botYOUR_TOKEN/getUpdates"- Look for:
"chat":{"id":123456789}Add the ID to config.conf:
TELEGRAM_CHAT_ID="123456789"Now your bot will send notifications whenever a brute-force attempt is detected.