<?xml version="1.0" encoding="UTF-8"?>

<rss version="2.0"
 xmlns:blogChannel="http://backend.userland.com/blogChannelModule"
>

<channel>
<title><![CDATA[Dobrica Pavlinušić's random unstructured stuff: fail2ban]]></title>
<link>https://saturn.ffzg.hr/rot13/index.cgi?fail2ban</link>
<description></description>
<pubDate>Mon, 30 Nov 2020 08:46:56 -0000</pubDate>
<webMaster>root@saturn.ffzg.hr</webMaster>
<generator>Socialtext Workspace v2.19.0.2</generator>

<item>
<title><![CDATA[fail2ban]]></title>
<link>https://saturn.ffzg.hr/rot13/index.cgi?fail2ban</link>
<description><![CDATA[<div>Creator: Dobrica Pavlinušić</div><hr/><div class="wiki">
<p>
fail2ban seems to accumulate records in sqlite database forever.</p>
<p>
<a target="_blank" title="(external link)" href="https://github.com/ffzg/fail2ban-helpers">https://github.com/ffzg/fail2ban-helpers</a></p>
<h1 id="check_bans_in_database">check bans in database</h1>
<pre>
dpavlin@mjesec:/var/lib/fail2ban$ ls -alh
total 165M
drwxr-xr-x  2 root root 4.0K May 12  2020 .
drwxr-xr-x 82 root root 4.0K May 12  2020 ..
-rw-------  1 root root 165M Nov 30 09:30 fail2ban.sqlite3
dpavlin@mjesec:/var/lib/fail2ban$ sqlite3 fail2ban.sqlite3
Error: unable to open database &quot;fail2ban.sqlite3&quot;: unable to open database file
dpavlin@mjesec:/var/lib/fail2ban$ sudo sqlite3 fail2ban.sqlite3

sqlite&gt; select datetime(min(timeofban),'unixepoch'),datetime(max(timeofban),'unixepoch') from bans ;
2020-05-12 18:25:57|2020-11-30 08:34:41

</pre>
<br /><h1 id="cleanup_old_entries">cleanup old entries</h1>
<pre>
dpavlin@syslog:~$ cat /etc/cron.daily/fail2ban-sqlite
#!/bin/sh

sqlite3 /var/lib/fail2ban/fail2ban.sqlite3 &quot;delete from bans where timeofban &lt;= strftime('%s', date('now', '-30 days'));&quot;
sqlite3 /var/lib/fail2ban/fail2ban.sqlite3 &quot;vacuum;&quot;

</pre>
</div>
]]></description>
<author>Dobrica Pavlinu&#x161;i&#x107;</author>
<category></category>
<guid isPermaLink="true">https://saturn.ffzg.hr/rot13/index.cgi?fail2ban</guid>
<pubDate>Mon, 30 Nov 2020 08:46:56 -0000</pubDate>
</item>
</channel>
</rss>