Last active
May 3, 2022 08:08
-
-
Save meinside/bdbcfc1c15bc6aca57bada57dcce06c0 to your computer and use it in GitHub Desktop.
Notify with pushbullet message on fail2ban's ban actions
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
#!/bin/bash | |
# | |
# notify-fail2ban.sh | |
# | |
# Notifies on fail2ban's ban actions through pushbullet | |
# | |
# NOTE: this script will be run as root, so don't forget to put related config files under /root/.config/ | |
# | |
# USAGE: $ ./notify-fail2ban.sh 8.8.8.8 ssh | |
# | |
# | |
# last update: 2019.06.05. | |
# | |
# by [email protected] | |
# binary paths | |
# | |
# go get -u github.com/meinside/ipstack-go/cmd/ip2loc | |
LOCATOR=/path/to/ip2loc | |
# go get -u github.com/meinside/pb-send | |
SENDER=/path/to/pb-send | |
# command line params | |
IP=$1 | |
PORT=$2 | |
# fetch location, | |
LOCATION=`$LOCATOR "$IP"` | |
MESSAGE="`hostname` fail2ban banned $PORT: $LOCATION" | |
# and run sender | |
$SENDER "$MESSAGE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment