diff --git a/ddos-mitigator.sh b/ddos-mitigator.sh index 80ade70..cbe0051 100755 --- a/ddos-mitigator.sh +++ b/ddos-mitigator.sh @@ -370,7 +370,12 @@ sudo -k # one of them. while read -r addr ; do echo "Banning ${addr} ..." - sudo fail2ban-client set apache-badbots banip "${addr}" + if [[ $(id -un) == "root" ]] ; then + # Don't use sudo when we're running as root. + fail2ban-client set apache-auth banip "${addr}" + else + sudo fail2ban-client set apache-auth banip "${addr}" + fi done < "${banlist}" echo -e "${green}All done!${reset}"