<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://pbs.proxmox.com/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Fail2ban</id>
	<title>Fail2ban - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pbs.proxmox.com/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Fail2ban"/>
	<link rel="alternate" type="text/html" href="https://pbs.proxmox.com/mediawiki/index.php?title=Fail2ban&amp;action=history"/>
	<updated>2026-05-16T00:01:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://pbs.proxmox.com/mediawiki/index.php?title=Fail2ban&amp;diff=128&amp;oldid=prev</id>
		<title>S.ivanov: Add initial page - adaptations contributed by Lukas Fülling</title>
		<link rel="alternate" type="text/html" href="https://pbs.proxmox.com/mediawiki/index.php?title=Fail2ban&amp;diff=128&amp;oldid=prev"/>
		<updated>2024-05-27T16:19:02Z</updated>

		<summary type="html">&lt;p&gt;Add initial page - adaptations contributed by Lukas Fülling&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Here we describe in short how you can set up &amp;lt;code&amp;gt;fail2ban&amp;lt;/code&amp;gt; for the Proxmox Backup Server API to block IP addresses (temporarily) if there were too many wrong login attempts submitted through them.&lt;br /&gt;
The page is based upon the [https://pve.proxmox.com/wiki/Fail2ban HOWTO for Proxmox VE]&lt;br /&gt;
&lt;br /&gt;
== Install fail2ban ==&lt;br /&gt;
&lt;br /&gt;
Execute the following commands as root in a shell on the Proxmox Backup Server host, for example connected through SSH or via the web console in the Proxmox Backup Server web interface.&lt;br /&gt;
&lt;br /&gt;
 apt update&lt;br /&gt;
 apt install fail2ban&lt;br /&gt;
&lt;br /&gt;
== Setup Base Config ==&lt;br /&gt;
&lt;br /&gt;
We recommend to use the &amp;lt;code&amp;gt;/etc/fail2ban/jail.local&amp;lt;/code&amp;gt; file, as settings in this file take precedence over identical settings of &amp;lt;code&amp;gt;jail.conf&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;jail.conf&amp;lt;/code&amp;gt; as a template:&lt;br /&gt;
&lt;br /&gt;
 cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local&lt;br /&gt;
&lt;br /&gt;
And adapt the settings to your needs in the copied over &amp;lt;code&amp;gt;jail.local&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The main reason for using this separate file is that the original &amp;lt;code&amp;gt;jail.conf&amp;lt;/code&amp;gt; could be overwritten by fail2ban package updates, while the copied &amp;lt;code&amp;gt;jail.local&amp;lt;/code&amp;gt; will not, so you can better manage updates that way.&lt;br /&gt;
&lt;br /&gt;
== Setup Jail ==&lt;br /&gt;
&lt;br /&gt;
=== Base Config ===&lt;br /&gt;
Add the following to the end of the copied over file &amp;lt;code&amp;gt;/etc/fail2ban/jail.local&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[proxmox-backup-server]&lt;br /&gt;
enabled = true&lt;br /&gt;
port = https,http,8007&lt;br /&gt;
filter = proxmox-backup-server&lt;br /&gt;
logpath = /var/log/proxmox-backup/api/auth.log&lt;br /&gt;
maxretry = 3&lt;br /&gt;
findtime = 2d&lt;br /&gt;
bantime = 1h&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tip: Time properties like &amp;lt;code&amp;gt;bantime&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;findtime&amp;lt;/code&amp;gt; also allow combinations like &amp;lt;code&amp;gt;2m 30s&amp;lt;/code&amp;gt;. You can test if a value is valid and what the actually resulting ban seconds are using the &amp;lt;code&amp;gt;fail2ban-client --str2sec &amp;#039;1d 12h&amp;#039;&amp;lt;/code&amp;gt; command.&lt;br /&gt;
See the &amp;lt;code&amp;gt;jail.conf&amp;lt;/code&amp;gt; manual page&amp;lt;ref&amp;gt;&amp;lt;code&amp;gt;jail.conf&amp;lt;/code&amp;gt; manual page https://manpages.debian.org/stable/fail2ban/jail.conf.5.en.html&amp;lt;/ref&amp;gt; for description of all options.&lt;br /&gt;
&lt;br /&gt;
=== Filter Config ===&lt;br /&gt;
Create the file &amp;lt;code&amp;gt;/etc/fail2ban/filter.d/proxmox-backup-server.conf&amp;lt;/code&amp;gt; with the following content:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Definition]&lt;br /&gt;
failregex = authentication failure; rhost=\[&amp;lt;HOST&amp;gt;\]:\d+ user=.* msg=.*&lt;br /&gt;
ignoreregex =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Restart Service to Enable Config ===&lt;br /&gt;
Use:&lt;br /&gt;
 systemctl restart fail2ban&lt;br /&gt;
to activate the config addition and arm fail2ban for the Proxmox Backup Server API.&lt;br /&gt;
&lt;br /&gt;
== Test fail2ban Config ==&lt;br /&gt;
You can test your configuration by trying to log in through the web interface with a wrong password or a wrong user, and then issue the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
fail2ban-regex /var/log/proxmox-backup/api/auth.log /etc/fail2ban/filter.d/proxmox-backup-server.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should have *at least* a &amp;quot;Failregex: 1 total&amp;quot; at the top of the &amp;quot;Results&amp;quot; section (and &amp;quot;1 matched&amp;quot; at the bottom)&lt;br /&gt;
&lt;br /&gt;
Note, if you tried too often and got yourself banned (your IP is reported by &amp;lt;code&amp;gt;fail2ban-client get proxmox-backup-server banned&amp;lt;/code&amp;gt;) you can use &amp;lt;code&amp;gt;fail2ban-client unban &amp;lt;IP&amp;gt;&amp;lt;/code&amp;gt; (replace &amp;lt;code&amp;gt;&amp;lt;IP&amp;gt;&amp;lt;/code&amp;gt; with the IP address) to manually unblock yourself.&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
* [http://www.fail2ban.org/wiki/index.php/Main_Page  Fail2Ban ]&lt;br /&gt;
&lt;br /&gt;
[[Category: HOW-TO]]&lt;/div&gt;</summary>
		<author><name>S.ivanov</name></author>
	</entry>
</feed>