Score:0

Ubuntu: Execute shell script with fail2ban when user fails to log in ssh

mp flag

In my ubuntu server I use fail2ban to block repeated failed ssh logins, when fail2ban detects this I want to execute a shell script, is this possible to do?

My ssh jail:

[ssh]
findtime = 10m
maxretry = 3

My shell script is in this location:

/home/MyUser/scripts/send-mail

Also, how can I get the banned IP? I want to send that information too if possible

Score:0
jp flag

There are already predefined actions like /etc/fail2ban/action.d/sendmail.conf for sending email. You could simply enable one of them in your [ssd] jail with, e.g.,

sendmail[dest="[email][email protected][/email]", sender="[email][email protected][/email]", sendername="Fail2Ban",
gabogabans avatar
mp flag
the thing is I send mails with mailgun (I didnt configure postfix or similar) so I use curl to send mail with mailgun efficently, that's why I need to call sh script
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.