Skip to content

Instantly share code, notes, and snippets.

@bcomnes
Last active March 23, 2016 23:47
Show Gist options
  • Select an option

  • Save bcomnes/a300949ff83ec482b057 to your computer and use it in GitHub Desktop.

Select an option

Save bcomnes/a300949ff83ec482b057 to your computer and use it in GitHub Desktop.
command to ban an IP using sshguard. requires sudo/root
#!/usr/bin/env bash
USAGE="Usage: $0 ipv4-address"
BLACKLISTDB="/var/db/sshguard/blacklist.db"
if [ "$#" == "0" ]; then
echo "$USAGE"
exit 1
fi
TIMESTAMP=`date +%s`
SSH_IPV4_BAN="|100|4|"
IP=$1
echo "${TIMESTAMP}${SSH_IPV4_BAN}${IP}" >> ${BLACKLISTDB}
systemctl restart sshguard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment