machine hangs on occasion - correlated with ssh break-in attempts

Dewayne Geraghty dewayne_freebsd at
Thu Aug 21 23:52:49 UTC 2008

There are many excellent suggestions on how to deal with invalid/unauthorised access attempts via ssh.  I'd used sshguard for around 8 months but recently changed to bruteblock, both are in the ports/security.  sshguard was very easy to configure, via rc.conf arguments.    Bruteblock handled the same problem more elegantly: uses two processes one for monitoring audit.log, via a pipe and one for maintaining the ipfw table entries, it uses the ipfw table value with the date/time entered, and the C code is cleaner (some optimisations are possible but this is V0.5).  

If you'd like to try it here are the steps I used to get it going:

Install package

Configure /usr/local/etc/bruteblock-ssh.conf (Using regexp
from sample, but modify parameters to suite your environment.)

regexp      =
sshd.*Illegal user \S+ from (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})

regexp1     =
sshd.*Failed password for (?:illegal user )?\S+ from

# three failures in 3 minutes is blocked for a day, using ipfw2 table 10max_count   = 3

within_time = 180

reset_ip    = 86400

ipfw2_table_no = 10


Insert into "/etc/syslog.conf"; |exec /usr/local/sbin/bruteblock –f /usr/local/etc/bruteblock-ssh.conf
Add to firewall rules (and /etc/rc.firewall)ipfw add 4 deny ip from table\(10\) to any
ipfw add 4 deny ip from any to table\(10\) Add into /etc/rc.confbruteblockd_enable="YES"
bruteblockd_flags="-s 7200"  # How frequently to review the ipfw table for entry removal Now restart syslog, and start bruteblockd/etc/rc.d/syslogd restart
/usr/local/etc/rc.d/ start

      Win a MacBook Air or iPod touch with Yahoo!7.

More information about the freebsd-stable mailing list