-
-
Save yangwe1/73b38433d59cca46e29712a4098fa017 to your computer and use it in GitHub Desktop.
Fail2ban + Telegram using telegram-send
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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