Ever wished you could get instant notifications in Microsoft Teams when someone tries to break into your server? I've got you covered! I recently created a solution that bridges Fail2Ban security monitoring with Microsoft Teams notifications, complete with geographical information about potential attackers.

The Problem 🤔

As a system administrator, monitoring server security events can be challenging. Fail2Ban does an excellent job of detecting and blocking malicious activities, but by default, you only know about these events when you actively check the logs. What if you could get real-time notifications directly in your Teams workspace with detailed information about each security incident?

The Solution 💡

I developed fail2ban-ms-teams-notification, a comprehensive integration that sends detailed security alerts to Microsoft Teams channels whenever Fail2Ban detects suspicious activity.

Key Features ✨

How It Works 🔧

The integration consists of two main components:

  1. teams-geo.conf - A Fail2Ban action configuration file
  2. teams-notify.sh - A notification script that formats and sends alerts to Teams

When Fail2Ban detects suspicious activity, it triggers the Teams notification action, which:

Quick Setup Guide 🚀

Prerequisites

Installation Steps

  1. Clone the repository

    git clone https://github.com/eyeskiller/fail2ban-ms-teams-notification.git cd fail2ban-ms-teams-notification

  2. Install the components

    `# Copy action configuration sudo cp teams-geo.conf /etc/fail2ban/action.d/teams-geo.conf

    Copy notification script

    sudo cp teams-notify.sh /etc/fail2ban/teams-notify.sh sudo chmod +x /etc/fail2ban/teams-notify.sh`

  3. Configure your Teams webhook

    `sudo nano /etc/fail2ban/teams-notify.sh

    Update the WEBHOOK variable with your Teams webhook URL`

  4. Add to your jail configurations

    [sshd] enabled = true port = ssh logpath = %(sshd_log)s maxretry = 3 findtime = 600 bantime = 3600 action = %(action_)s teams-geo

  5. Restart and test

    sudo systemctl restart fail2ban sudo /etc/fail2ban/teams-notify.sh "192.168.1.100" "test-jail" "manual-test"

Real-World Usage Examples 🌍

SSH Protection

Perfect for monitoring SSH login attempts on your servers. You'll get instant alerts when someone tries to brute-force your SSH service.

Web Server Security

Integrate with Nginx or Apache logs to monitor HTTP authentication failures and suspicious web activity.

Custom Applications

Easily extend to any service that logs security events by creating custom Fail2Ban jail configurations.

What Makes This Special? 🌟

Unlike basic notification solutions, this integration provides:

Troubleshooting Made Easy 🔍

The repository includes comprehensive troubleshooting guides for common issues:

Security Considerations 🔒

When implementing this solution, consider:

Future Enhancements 🚀

I'm continuously improving this integration. Planned features include:

Get Started Today!

Ready to enhance your server security monitoring? Check out the repository on GitHub and start receiving real-time security alerts in your Microsoft Teams workspace.

The setup takes less than 10 minutes, but the peace of mind is invaluable. Your future self will thank you when you catch that next security incident in real-time instead of discovering it days later in log files!