From ced713fe23ae582d6d798895ac107e2255d386b6 Mon Sep 17 00:00:00 2001 From: Chuck Date: Thu, 7 Nov 2024 12:45:37 -0500 Subject: [PATCH] Add Fail2Ban Telegram action configuration --- action.d/telegram.conf | 72 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 action.d/telegram.conf diff --git a/action.d/telegram.conf b/action.d/telegram.conf new file mode 100644 index 0000000..bb66e2f --- /dev/null +++ b/action.d/telegram.conf @@ -0,0 +1,72 @@ +## Version 2024/11/07 +# Fail2Ban configuration file +# +# Author: smith8ca +# +# Add the following to jail.local (uncommented) to apply the telegram action to all bans with all jails +# Update the bot_token and chat_id (within the Init section) with your own values from Telegram's BotFather +# +# + +[Definition] + +# Option: actionstart +# Notes.: command executed once at the start of Fail2Ban. +# Values: CMD +# +# Comment out this action as necessary +actionstart = curl -X POST -H Content-Type:application/json /sendMessage \ + --data '{ "text": "Started ", "chat_id": "" }' + +# Option: actionstop +# Notes.: command executed once at the end of Fail2Ban +# Values: CMD +# +# Comment out this action as necessary +actionstop = curl -X POST -H Content-Type:application/json /sendMessage \ + --data '{ "text": "Stopped ", "chat_id": "" }' + +# Option: actioncheck +# Notes.: command executed once before each actionban command +# Values: CMD +# +actioncheck = + +# Option: actionban +# Notes.: command executed when banning an IP. Take care that the +# command is executed with Fail2Ban user rights. +# Tags: See jail.conf(5) man page +# Values: CMD +# +actionban = curl -X POST -H Content-Type:application/json /sendMessage \ + --data '{ "text": ": got banned for seconds after tries.\n\nUnban command:\nfail2ban-client unban ", "chat_id": "" }' + +# Option: actionunban +# Notes.: command executed when unbanning an IP. Take care that the +# command is executed with Fail2Ban user rights. +# Tags: See jail.conf(5) man page +# Values: CMD +# +actionunban = curl -X POST -H Content-Type:application/json /sendMessage \ + --data '{ "text": ": is now unbanned", "chat_id": "" }' + + +[Init] + +# Option: bot_token +# Notes.: The token of the telegram bot +# Values: [ STRING ] +# +bot_token = + +# Option: chat_id +# Notes.: The chat id of the telegram user or group +# Values: [ STRING ] +# +chat_id = + +# Option: url +# Notes.: The url of the telegram API +# Values: [ STRING ] +# +url = https://api.telegram.org/bot