Fail2ban – how to unbanip on your sshd

IP address unban

Fail2Ban is an intrusion prevention software that protects computer servers against brute-force attacks. It monitors certain logs and will ban IP addresses that show brute-force-like behavior.

In particular, Fail2Ban monitors SSH connection attempts. After 5 failed SSH connection attempts, Fail2Ban will ban the IP address from connecting via SSH for 10 minutes. If this address fails several times, it might get banned for a permanent until you contact and explain why you brute-force attacks on my server.

Unban an IP address

To unblock an IP address, you must first access your server by some means (for example from another IP address or from another internet connection than the banned one).

Then, look at the Fail2Ban’s log to identify in which jail the IP address has been banned:

sudo tail /var/log/fail2ban.log
2019-01-07 16:24:47 fail2ban.filter  [1837]: INFO    [sshd] Found
2019-01-07 16:24:49 fail2ban.filter  [1837]: INFO    [sshd] Found
2019-01-07 16:24:51 fail2ban.filter  [1837]: INFO    [sshd] Found
2019-01-07 16:24:54 fail2ban.filter  [1837]: INFO    [sshd] Found
2019-01-07 16:24:57 fail2ban.filter  [1837]: INFO    [sshd] Found
2019-01-07 16:24:57 fail2ban.actions [1837]: NOTICE  [sshd] Ban
2019-01-07 16:24:57 fail2ban.filter  [1837]: NOTICE  [recidive] Ban

Here, the IP address has been banned in the sshd and recidive jails.

Then unban the IP address with the following commands:

sudo fail2ban-client set sshd unbanip
sudo fail2ban-client set recidive unbanip