Fail2ban unlock an IP

# fail2ban-client status 
Status 
|- Number of jail:      11 
`- Jail list:   plesk-apache, plesk-apache-badbot, plesk-dovecot, plesk-modsecurity, plesk-panel, plesk-postfix, plesk-proftpd, plesk-roundcube,
plesk-wordpress, recidive, ssh

In Fail2ban version(before v0.8.8)
fail2ban-client get yourjailname actionunban youripaddress
For example
fail2ban-client get ssh actionunban 10.xx.15x.12x

Fail2Ban v0.9.3, the command to unban is “unbanip”
fail2ban-client set yourjailname unbanip youripaddress
 
Thanks a lot for your article. It helped me write this small bash script to unban an ip from a fail2ban jail. The jail name is retrieved from /var/log/fail2ban.log if ip is found there. Otherwise, the fallback jail name is sshd.

#!/bin/bash

logfile=’/var/log/fail2ban.log’
fallbackjail=’sshd’

echo “Enter ip to unban:”
read ip

echo “Checking whether the ip is banned”
if [ 0 -lt `iptables -n -L|grep “REJECT”|grep “\”|wc -l` ]
then
echo “The ip $ip is banned”
else
echo “The ip $ip is not banned, ABORTING”
exit
fi

echo “Trying to guess the jail name from $logfile”
jail=`grep “Ban $ip$” $logfile|cut -d ‘[‘ -f 3|cut -d ‘]’ -f 1`
if [ 0 -lt ${#jail} ]
then
echo “Found jail $jail for this ip”
else
echo “No jail found assuming $fallbackjail”
jail=$fallbackjail
fi

echo “Checking that jail exists”
exists=`fail2ban-client status|grep “$jail”`
if [ 0 -lt ${#exists} ]
then
echo “Jail $jail exists”
else
echo “Jail $jail doesn’t exist, ABORTING”
exit
fi

echo “Unbanning ip $ip from jail $jail”
fail2ban-client set $jail unbanip $ip

Article reference here