Skip to content

deividgdt/fail2ban_telegram_notifications

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fail2ban Telegram Notifications

Sending fail2ban notifications using a Telegram bot

Installation and configuration

  • Add the following two lines, for example, to SSHD in the file /etc/fail2ban/jail.conf, make sure to tab the word telegram.

    action  = iptables[name=SSH, port=22, protocol=tcp]
    		telegram

    Example:

  • Download the file telegram.conf and move it to /etc/fail2ban/action.d/

  • Download the file send_telegram_notif.sh move it to /etc/fail2ban/scripts/

  • Modify the file /etc/fail2ban/scripts/send_telegram_notif.sh and add your Token and your Chat ID:

    telegramBotToken=YOUR_BOT_TOKEN
    telegramChatID=YOUR_CHAT_ID
  • Make the file executable

    chmod +x /etc/fail2ban/scripts/send_telegram_notif.sh
  • Restart the fail2ban service and enjoy!

    systemctl restart fail2ban

Usage

  • /etc/fail2ban/scripts/send_telegram_notif.sh -a [ start || stop ] || [ -n $NAME -b $IP || -n $NAME -u $IP ]"
    • -a (action)
    • -n (jail name)
    • -b (ban)
    • -u (unban)

Buy me a coffe

ko-fi