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
#!/usr/bin/env bash | |
# log could be /var/log/secure or /var/log/auth.log | |
zgrep -P 'Invalid user .+? from |Failed password for .+? from ' /var/log/auth.log* \ | |
| grep -Pv $WHITELISTIPS \ | |
| perl -p -e 's/.+? from (\d+\.\d+\.\d+\.\d+) port .+/\1/g' \ | |
| sort -u \ | |
| xargs -I % sudo cscli decisions add --ip % --duration 48h --reason "ssh bruteforce" |
OlderNewer