Skip to content

Instantly share code, notes, and snippets.

@yangwe1
Forked from CHERTS/how-to-install-telegram-send
Created October 29, 2019 02:12
Show Gist options
  • Save yangwe1/73b38433d59cca46e29712a4098fa017 to your computer and use it in GitHub Desktop.
Save yangwe1/73b38433d59cca46e29712a4098fa017 to your computer and use it in GitHub Desktop.
Fail2ban + Telegram using telegram-send
# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.9 (jessie)
Release: 8.9
Codename: jessie
Installing telegram-send
# pip install telegram-send
Enter chat_id and token for Telegram bot:
# telegram-send --configure
Testing
# /usr/local/bin/telegram-send --format markdown Test
# File /etc/fail2ban/jail.conf
[ssh]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 6
action = %(action_)s
telegram[name=SSH]
# File /etc/fail2ban/action.d/telegram.conf
[Definition]
actionstart = /usr/local/bin/telegram-send --format markdown "[Fail2Ban] The jail <name> has been started on `uname -n` successfully."
actionstop = /usr/local/bin/telegram-send --format markdown "[Fail2Ban] The jail <name> has been stopped on `uname -n`."
actioncheck =
actionban = /usr/local/bin/telegram-send --format markdown "[Fail2Ban] The IP <ip> has just been banned by Fail2Ban after <failures> attempts against <name> from `uname -n`"
actionunban = /usr/local/bin/telegram-send --format markdown "[Fail2Ban] The IP <ip> has just been unbanned by Fail2Ban after <failures> attempts against <name> from `uname -n`"
[Init]
init = 'Fail2Ban Telegram plugins activated"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment