<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>rasberry pi Archives - ITBlogSec.com</title>
	<atom:link href="https://itblogsec.com/tag/rasberry-pi/feed/" rel="self" type="application/rss+xml" />
	<link>https://itblogsec.com/tag/rasberry-pi/</link>
	<description>IT, network, security and hacking</description>
	<lastBuildDate>Thu, 14 Jan 2021 22:38:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
	<item>
		<title>How to install Fail2Ban on the Raspberry Pi/Unix server</title>
		<link>https://itblogsec.com/how-to-install-fail2ban-on-the-raspberry-pi-unix-server/</link>
					<comments>https://itblogsec.com/how-to-install-fail2ban-on-the-raspberry-pi-unix-server/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 14 Jan 2021 22:19:36 +0000</pubDate>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Other]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[rasberry pi]]></category>
		<guid isPermaLink="false">https://itblogsec.com/?p=1335</guid>

					<description><![CDATA[<p>By opening ports from the Internet to your raspberry pi (ssh, http, ftp, https etc.), you are automatically becoming a victim of many hacker's attempts. Hackers are seeking exploits and trying to get access to your server. To protect you against such attacks, there is a tool called Fail2Ban. It supports a lot of services (sshd, apache, qmail, proftpd etc.) and can be integrated directly with your IPTables. By this tutorial, we will guide you via the whole process of how to protect against such attacks.   </p>
<p>The post <a href="https://itblogsec.com/how-to-install-fail2ban-on-the-raspberry-pi-unix-server/">How to install Fail2Ban on the Raspberry Pi/Unix server</a> appeared first on <a href="https://itblogsec.com">ITBlogSec.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3>How to install Fail2Ban on the Raspberry Pi/Unix server</h3>
<p style="text-align: justify;">By <strong>opening ports from the Internet</strong> to your raspberry pi <strong>(ssh, http, ftp, https etc.)</strong>, you are automatically becoming a <strong>victim</strong> of many <strong>hacker&#8217;s attempts</strong>. Hackers are seeking <strong>exploits</strong> and trying <strong>to get access to your server.</strong> To protect you against such attacks, there is a <strong>tool called Fail2Ban</strong>. It supports a lot of services (sshd, apache, qmail, proftpd etc.) and can be integrated directly with your <strong>IPTables</strong>. By this tutorial, we will guide you via the whole process of how to protect against such attacks.   </p>
<h5 style="text-align: justify;">Who is trying to access my raspberry pi?</h5>
<p style="text-align: justify;">If you think that your raspberry pi is safe and you do not need any tool to be installed, please <strong>check the content</strong> of the following <strong>file</strong>:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="godzilla">cat /var/log/auth.log | grep 'Failed'</pre>
<p><a href="https://itblogsec.com/wp-content/uploads/2021/01/Pictures.png"><img fetchpriority="high" decoding="async" class="aligncenter size-full wp-image-1346" src="https://itblogsec.com/wp-content/uploads/2021/01/Pictures.png" alt="" width="843" height="189" srcset="https://itblogsec.com/wp-content/uploads/2021/01/Pictures.png 843w, https://itblogsec.com/wp-content/uploads/2021/01/Pictures-300x67.png 300w, https://itblogsec.com/wp-content/uploads/2021/01/Pictures-768x172.png 768w, https://itblogsec.com/wp-content/uploads/2021/01/Pictures-585x131.png 585w" sizes="(max-width: 843px) 100vw, 843px" /></a></p>
<p style="text-align: justify;">As you can observe above, there are <strong>many password failures</strong>. Usually, the hacker bots are <strong>seeking exploits</strong>.  Each attempt <strong>consumes resources</strong> as your raspberry pi needs to evaluate each request. It is known as DoS attack. </p>
<p style="text-align: justify;">Hackers can try also a <b>brute-force attack. </b> Such an attack consists of an attacker submitting many passwords or passphrases with the hope of eventually <strong>guessing a combination correctly</strong>. The attacker <strong>systematically</strong> <strong>checks</strong> all <strong>possible passwords</strong> and passphrases until the correct one is found. </p>
<h5 style="text-align: justify;">What is Fail2Ban and how does it work?</h5>
<p style="text-align: justify;">Fail2Ban is a <strong>daemon</strong> that <strong>scans access log files</strong> and it bans IP addresses that <strong>show malicious signs</strong>. It <strong>protects</strong> you <strong>against</strong> <strong>too many password failures</strong> as shown above. </p>
<p style="text-align: justify;">It is a <strong>must have tool</strong> to <strong>protect</strong> your <strong>from intruders</strong> to your server or network <strong>especially</strong> if you allow <strong>outside SSH</strong> traffic or any traffics from an outside network to your Raspberry Pi. Fail2Ban tool <strong>supports many different services</strong> <strong>(sshd, apache, qmail, proftpd, sasl, asterisk, etc) </strong>and can be <strong>integrated</strong> with your <strong>IPTables</strong>.</p>
<p style="text-align: justify;"><strong>Installation</strong> of Fail2Ban is very <strong>easy</strong> to install and basic setup <strong>will drastically improve security</strong> on your Raspberry Pi. Fail2Ban works by <strong>checking your access logs for failures</strong> and depending on the settings you setup, <strong>it will ban</strong> or timeout an IP Address for a certain amount of time. Fail2Ban tool can easily protect your raspberry pi against very known brute-force and DoS attacks.</p>
<h5 style="text-align: justify;">How can I protect myself?</h5>
<p style="text-align: justify;">Very easy, by installing of Fail2Ban on your raspberry pi. We will first <strong>install Fail2Ban</strong> by typing the following commands:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="godzilla">sudo apt-get update
sudo apt-get install fail2ban</pre>
<p style="text-align: justify;">By doing that, you have Fail2Ban already installed. The <strong>configuration file</strong> is located at <strong>&#8216;/etc/fail2ban/jail.local&#8217;</strong>. If you want to change some parameters, you can simply <strong>modify this file</strong> and <strong>restart the service</strong> to take immediate effect.</p>
<p style="text-align: justify;">Let&#8217;s edit our SSH Fail2Ban configurations. Open up the &#8216;/etc/fail2ban/jail.local&#8217; file with the following command:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="godzilla">sudo nano /etc/fail2ban/jail.local</pre>
<p style="text-align: justify;">Your <strong>jail.local file should already contain</strong> some <strong>pre-defined config.</strong> We will need to tweak it a little bit. Find a section in the file called <strong>[sshd]</strong> and paste/modify accordingly:</p>
<div id="crayon-5fdbb26ace0f1756477449-1" class="crayon-line">
<div id="crayon-5fdbb26ace0f1756477449-1" class="crayon-line">
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="godzilla">[sshd]

enabled = true
filter = sshd
port = ssh
logpath = /var/log/auth.log
bantime = 86400
banaction = iptables-allports
findtime = 900
maxretry = 3
backend = %(sshd_backend)s</pre>
<p style="text-align: justify;">After pasting the settings hit CTRL+X and then Y to save the configuration file. Below is what each line in the configuration means and what you can edit:</p>
<p style="text-align: justify;"><strong><em>enabled</em></strong>: Determines whether or not the filter is turned on.</p>
<p style="text-align: justify;"><em><strong>filter</strong></em>: The name of the file located in ‘/etc/fail2ban/filter.d’ that contains the failregex information used to parse log files appropriately.</p>
<p style="text-align: justify;"><em><strong>port</strong></em>: The port Fail2Ban should be referencing in regards to the service. If using the default port, then the service name can be placed here. If you changed your SSH port to something else you would need to write the new port number here.</p>
<p style="text-align: justify;"><em><strong>logpath</strong></em>: The path to your log file.</p>
<p style="text-align: justify;"><em><strong>bantime</strong></em>: The length of time in seconds that the IP Address will be banned for. In my example I used ‘86400’ seconds which would be 24 hours. If you want to ban an IP Address permanently then you will set the <em><strong>bantime</strong></em> to ‘-1’.</p>
<p style="text-align: justify;"><em><strong>banaction</strong></em>: The action to take when banning an IP Address.</p>
<p style="text-align: justify;"><em><strong>findtime</strong></em>: The length of time between login attempts before a ban is set. For example, if Fail2Ban is set to ban an IP after three failed log-in attempts, those three attempts must occur within the set <em><strong>findtime</strong></em> limit. The <em><strong>findtime</strong></em> value should be a set number of seconds.</p>
<p style="text-align: justify;"><em><strong>maxretry</strong></em>: How many attempts can be made to access the server from a single IP before a ban is imposed.</p>
<p style="text-align: justify;">After modification of the configuration file, you need to restart the service to take changes affect:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="godzilla">sudo service fail2ban restart</pre>
<p style="text-align: justify;">After the restart of service, <strong>your raspberry pi is already protected</strong> and all <strong>DoS</strong> or <strong>brute-force attempts</strong> will be <strong>banned</strong>. The list of all <strong>banned IPs</strong> is <strong>cleared</strong> upon<strong> restarting Fail2Ban</strong> or <strong>rebooting</strong> the <strong>server</strong>. If you manage to ban yourself, you can simply reboot the server or use the command below:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="godzilla">sudo fail2ban-client set sshd unbanip &lt;IP-YOU-WANT-TO-UNBAN&gt;</pre>
<p style="text-align: justify;">You can <strong>check</strong> your <strong>IPTables</strong> <strong>list</strong> with the following command to see <strong>all your banned IP</strong> addresses:</p>
</div>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="godzilla">sudo iptables -L -n --line</pre>
<p><span style="font-size: 8pt;"><strong>source:</strong> <a href="https://en.wikipedia.org/wiki/Brute-force_attack" target="_blank" rel="noopener">https://en.wikipedia.org/wiki/Brute-force_attack</a>, <a href="https://www.fail2ban.org/wiki/index.php/Main_Page" target="_blank" rel="noopener">https://www.fail2ban.org/wiki/index.php/Main_Page</a></span></p>
</div>
<p>The post <a href="https://itblogsec.com/how-to-install-fail2ban-on-the-raspberry-pi-unix-server/">How to install Fail2Ban on the Raspberry Pi/Unix server</a> appeared first on <a href="https://itblogsec.com">ITBlogSec.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://itblogsec.com/how-to-install-fail2ban-on-the-raspberry-pi-unix-server/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/

Object Caching 0/149 objects using XCache
Page Caching using Disk: Enhanced 

Served from: itblogsec.com @ 2025-12-01 03:36:40 by W3 Total Cache
-->