<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://www.kevinlee.io/w/skins/common/feed.css?270"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
		<id>https://www.kevinlee.io/w/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://www.kevinlee.io/w/index.php?action=history&amp;feed=atom&amp;title=Fail2Ban"/>
		<link rel="alternate" type="text/html" href="https://www.kevinlee.io/w/index.php?title=Fail2Ban&amp;action=history"/>
		<updated>2026-05-06T07:35:49Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.16.0</generator>

	<entry>
		<id>https://www.kevinlee.io/w/index.php?title=Fail2Ban&amp;diff=133&amp;oldid=prev</id>
		<title>Kevin at 06:27, 3 April 2009</title>
		<link rel="alternate" type="text/html" href="https://www.kevinlee.io/w/index.php?title=Fail2Ban&amp;diff=133&amp;oldid=prev"/>
				<updated>2009-04-03T06:27:38Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 06:27, 3 April 2009&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 8:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 8:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Check if it is already installed. If it is not installed yet, install it first.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Check if it is already installed. If it is not installed yet, install it first.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;$ sudo apt-get install iptables&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;$ sudo apt-get install iptables &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 14:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 14:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Fail2ban also uses &amp;lt;code&amp;gt;sendmail&amp;lt;/code&amp;gt; mail transfer agent (MTA) to send an email in order to report the failure of login. This can be optional, yet it is better to have the report thus installing &amp;lt;code&amp;gt;sendmail&amp;lt;/code&amp;gt; is recommended.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Fail2ban also uses &amp;lt;code&amp;gt;sendmail&amp;lt;/code&amp;gt; mail transfer agent (MTA) to send an email in order to report the failure of login. This can be optional, yet it is better to have the report thus installing &amp;lt;code&amp;gt;sendmail&amp;lt;/code&amp;gt; is recommended.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;$ sudo apt-get install sendmail&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;$ sudo apt-get install sendmail &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 20:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 20:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Installation ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== Installation ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;$ sudo apt-get install fail2ban&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;$ sudo apt-get install fail2ban &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 27:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 27:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;It has a default configuration file which is &amp;lt;code&amp;gt;jail.conf&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;/etc/fail2ban&amp;lt;/code&amp;gt; directory. However, using &amp;lt;code&amp;gt;/etc/fail2ban/jail.local&amp;lt;/code&amp;gt; file is encouraged. If there is no such a file, create one and copy the contents of the &amp;lt;code&amp;gt;jail.conf&amp;lt;/code&amp;gt; file. Or just simply copy &amp;lt;code&amp;gt;/etc/fail2ban/jail.conf&amp;lt;/code&amp;gt; file to &amp;lt;code&amp;gt;/etc/fail2ban/jail.local&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;It has a default configuration file which is &amp;lt;code&amp;gt;jail.conf&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;/etc/fail2ban&amp;lt;/code&amp;gt; directory. However, using &amp;lt;code&amp;gt;/etc/fail2ban/jail.local&amp;lt;/code&amp;gt; file is encouraged. If there is no such a file, create one and copy the contents of the &amp;lt;code&amp;gt;jail.conf&amp;lt;/code&amp;gt; file. Or just simply copy &amp;lt;code&amp;gt;/etc/fail2ban/jail.conf&amp;lt;/code&amp;gt; file to &amp;lt;code&amp;gt;/etc/fail2ban/jail.local&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;$ sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;$ sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 74:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 74:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== Restart Fail2Ban ===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== Restart Fail2Ban ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;$ sudo /etc/init.d/fail2ban restart&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;$ sudo /etc/init.d/fail2ban restart &amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Kevin</name></author>	</entry>

	<entry>
		<id>https://www.kevinlee.io/w/index.php?title=Fail2Ban&amp;diff=45&amp;oldid=prev</id>
		<title>Kevin at 09:55, 3 October 2008</title>
		<link rel="alternate" type="text/html" href="https://www.kevinlee.io/w/index.php?title=Fail2Ban&amp;diff=45&amp;oldid=prev"/>
				<updated>2008-10-03T09:55:18Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 09:55, 3 October 2008&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 48:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 48:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;''*&amp;lt;code&amp;gt;port = ssh&amp;lt;/code&amp;gt; is comment out yet &amp;lt;code&amp;gt;ssh&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sftp&amp;lt;/code&amp;gt; are set instead.''&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;''*&amp;lt;code&amp;gt;port = ssh&amp;lt;/code&amp;gt; is comment out yet &amp;lt;code&amp;gt;ssh&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sftp&amp;lt;/code&amp;gt; are set instead.''&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;It will email you when it detects the failure of the login attempt which happened more than &amp;lt;code&amp;gt;maxretry&amp;lt;/code&amp;gt;, 3 in this example, after banning the IP, from which the attempt of the access is.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;*&lt;/ins&gt;It will email you when it detects the failure of the login attempt which happened more than &amp;lt;code&amp;gt;maxretry&amp;lt;/code&amp;gt;, 3 in this example, after banning the IP, from which the attempt of the access is.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;*If you changed the port number used for sshd, then change&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; action&amp;nbsp;  = iptables[name=SSH, port=ssh, protocol=tcp]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;to&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; action&amp;nbsp;  = iptables[name=SSH, port='''&amp;lt;port number&amp;gt;''', protocol=tcp]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; e.g.)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; action&amp;nbsp;  = iptables[name=SSH, port='''1234''', protocol=tcp]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Kevin</name></author>	</entry>

	<entry>
		<id>https://www.kevinlee.io/w/index.php?title=Fail2Ban&amp;diff=14&amp;oldid=prev</id>
		<title>Kevin: New page: Category:Network == Fail2Ban == Fail2Ban is an intrusion prevention framework written in Python (programming language). It checks log files and uses firewall such as iptables and TCP W...</title>
		<link rel="alternate" type="text/html" href="https://www.kevinlee.io/w/index.php?title=Fail2Ban&amp;diff=14&amp;oldid=prev"/>
				<updated>2008-09-29T05:48:37Z</updated>
		
		<summary type="html">&lt;p&gt;New page: &lt;a href=&quot;/wiki/Category:Network&quot; title=&quot;Category:Network&quot;&gt;Category:Network&lt;/a&gt; == Fail2Ban == Fail2Ban is an intrusion prevention framework written in Python (programming language). It checks log files and uses firewall such as iptables and TCP W...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Network]]&lt;br /&gt;
== Fail2Ban ==&lt;br /&gt;
Fail2Ban is an intrusion prevention framework written in Python (programming language). It checks log files and uses firewall such as iptables and TCP Wrapper to ban IP which makes too many login failure.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
=== Iptables ===&lt;br /&gt;
As mentioned, it uses &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; so &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; (or other applicable firewall applications) should be installed beforehand.&lt;br /&gt;
Check if it is already installed. If it is not installed yet, install it first.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo apt-get install iptables&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sendmail ===&lt;br /&gt;
Fail2ban also uses &amp;lt;code&amp;gt;sendmail&amp;lt;/code&amp;gt; mail transfer agent (MTA) to send an email in order to report the failure of login. This can be optional, yet it is better to have the report thus installing &amp;lt;code&amp;gt;sendmail&amp;lt;/code&amp;gt; is recommended.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo apt-get install sendmail&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo apt-get install fail2ban&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
=== Create Configuration File (&amp;lt;code&amp;gt;jail.local&amp;lt;/code&amp;gt;) ===&lt;br /&gt;
It has a default configuration file which is &amp;lt;code&amp;gt;jail.conf&amp;lt;/code&amp;gt; in the &amp;lt;code&amp;gt;/etc/fail2ban&amp;lt;/code&amp;gt; directory. However, using &amp;lt;code&amp;gt;/etc/fail2ban/jail.local&amp;lt;/code&amp;gt; file is encouraged. If there is no such a file, create one and copy the contents of the &amp;lt;code&amp;gt;jail.conf&amp;lt;/code&amp;gt; file. Or just simply copy &amp;lt;code&amp;gt;/etc/fail2ban/jail.conf&amp;lt;/code&amp;gt; file to &amp;lt;code&amp;gt;/etc/fail2ban/jail.local&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Change &amp;lt;code&amp;gt;jail.local&amp;lt;/code&amp;gt; File ===&lt;br /&gt;
Find &amp;lt;code&amp;gt;[ssh]&amp;lt;/code&amp;gt; section and change like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[ssh]&lt;br /&gt;
&lt;br /&gt;
enabled = true&lt;br /&gt;
# port	= ssh&lt;br /&gt;
port	= ssh,sftp&lt;br /&gt;
filter	= sshd&lt;br /&gt;
logpath  = /var/log/auth.log&lt;br /&gt;
maxretry = 3&lt;br /&gt;
action   = iptables[name=SSH, port=ssh, protocol=tcp]&lt;br /&gt;
           sendmail-whois[name=SSH, dest=youremail@mail.com]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
''*&amp;lt;code&amp;gt;port = ssh&amp;lt;/code&amp;gt; is comment out yet &amp;lt;code&amp;gt;ssh&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sftp&amp;lt;/code&amp;gt; are set instead.''&lt;br /&gt;
&lt;br /&gt;
It will email you when it detects the failure of the login attempt which happened more than &amp;lt;code&amp;gt;maxretry&amp;lt;/code&amp;gt;, 3 in this example, after banning the IP, from which the attempt of the access is.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How long the IP is banned can be found from the &amp;lt;code&amp;gt;[DEFAULT]&amp;lt;/code&amp;gt; section&lt;br /&gt;
&lt;br /&gt;
 [DEFAULT]&lt;br /&gt;
 &lt;br /&gt;
 # &amp;quot;ignoreip&amp;quot; can be an IP address, a CIDR mask or a DNS host&lt;br /&gt;
 ignoreip = 127.0.0.1&lt;br /&gt;
 '''bantime  = 600'''&lt;br /&gt;
 maxretry = 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change it as you wish (it is seconds).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Restart Fail2Ban ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo /etc/init.d/fail2ban restart&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Bug ==&lt;br /&gt;
There is a known bug in fail2ban from Ubuntu (8.04) repository. The bug is that fail2ban is not started after rebooting.&lt;br /&gt;
The bug was reported [http://bugs.launchpad.net/ubuntu/+source/fail2ban/+bug/222804/ here].&lt;br /&gt;
&lt;br /&gt;
This can be solved by adding the line below to &amp;lt;code&amp;gt;/etc/init.d/fail2ban&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	[ -d /var/run/fail2ban ] || mkdir -p /var/run/fail2ban&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So it should be like this.&lt;br /&gt;
 		DAEMON_ARGS=&amp;quot;$DAEMON_ARGS -x&amp;quot;&lt;br /&gt;
 	fi&lt;br /&gt;
 &lt;br /&gt;
 	# Assure that /var/run/fail2ban exists. This line is added.&lt;br /&gt;
 	'''[ -d /var/run/fail2ban ] || mkdir -p /var/run/fail2ban'''&lt;br /&gt;
 &lt;br /&gt;
 	start-stop-daemon --start --quiet --chuid root --exec $DAEMON -- \&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[http://debaday.debian.net/2007/04/29/fail2ban-an-enemy-of-script-kiddies/ Fail2ban: an enemy of script-kiddies]&lt;/div&gt;</summary>
		<author><name>Kevin</name></author>	</entry>

	</feed>