Skip to content

Instantly share code, notes, and snippets.

@AlexandroPerez
Last active September 4, 2018 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AlexandroPerez/264fd6838db99074a26053a31187b265 to your computer and use it in GitHub Desktop.
Save AlexandroPerez/264fd6838db99074a26053a31187b265 to your computer and use it in GitHub Desktop.
Unban an IP from fail2ban

Unban an IP from fail2ban using interactive mode

the fail2ban-client has an interaction mode which will make it easy to unban an IP without many complications. To access interactive mode use:

$ fail2ban-client -i

once in interactive mode type ssh, or in some cases sshd (this was the case in my installation)

fail2ban> status ssh

you'll get something like this:

Status for the jail: ssh
|- Filter
|  |- Currently failed: 0
|  |- Total failed: 6
|  `- File list:    /var/log/auth.log
`- Actions
   |- Currently banned: 1
   |- Total banned: 2
   `- Banned IP list:   203.113.167.162

Under Banned IP list find the IP you want to unban, and then use the set ssh unbanip (or set sshd unbanip if you used status sshd above) command to unban the IP. Using the IP listed above as an example you would type:

fail2ban> set ssh unbanip 203.113.167.162

Once you do that the IP should no lonber be banned. You can proceed to exit the interactive mode

fail2ban> exit

To make sure the IP is no longer banned, you can check the ip tables:

$ iptables -L
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment