6

I use Ubuntu 16.04 server xenial. I use SSHguard in default conf (I didn't add any conf whatsoever).

How to free my IP if it was mistakenly blocked by SSHguard?

Say there was some kind of bug in SSHguard (as happened to me in the past with CSF-LFD) and my IP was blocked, how could I free it in SSHguard after logging in from either a VPN/adjacent computer/hosting provider's console ?

2
  • How did you configure it? What OS do you use? See the OS relevant firewall configurations, you should have rules for sshguard and you will need to remove some that match your IP being blocked. Commented Jan 30, 2018 at 15:20
  • I've edited with these details. Commented Jan 30, 2018 at 18:26

1 Answer 1

14

The Ubuntu Xenial sshguard package creates a sshguard firewall chain for both iptables and ip6tables (see file /usr/lib/sshguard/firewall if interested by details). So if you look into them you should find a rule banning your IP: use iptables -L -n -v sshguard. (I suppose from now on you are speaking about an IPv4 address, if it is IPv6 please replace iptables by ip6tables everywhere).

Then you either flush the chain completely, which would remove the ban for all IPs, yours and others, with iptables -F sshguard.

Or if you want to remove just your IP, you need first to redo the previous command with --line-numbers to find which number is the rule related to your IP and then you can do iptables -D sshguard NUM replacing NUM by the rule number as observed above.

That should then restore ssh access from the IP. No need to restart anything, firewall rules should be applied in real time, so your flush or deletion will be effective immediately.

Also you have an /etc/sshguard/whitelist file where you could add your IP, if it is a fixed one, to avoid the same problem in the future.

3
  • 1
    Thanks Patrick. I don't have enough rep to thumb up your answer. Commented Jan 30, 2018 at 19:32
  • No problem, glad it helped. Commented Jan 30, 2018 at 19:32
  • On Ubuntu 18.04, iptables -L -n -v sshguard didn't work, but iptables -n -v -L sshguard did work.
    – parkerfath
    Commented Feb 22 at 19:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .