<?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>protection Archives - Tech Chronicles</title>
	<atom:link href="http://kostacipo.stream/tag/protection/feed/" rel="self" type="application/rss+xml" />
	<link>https://kostacipo.stream/tag/protection/</link>
	<description>Ramblings of a Tech Dude</description>
	<lastBuildDate>Fri, 03 Jan 2020 11:21:43 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>

<image>
	<url>https://kostacipo.stream/wp-content/uploads/2019/12/cropped-profile-32x32.jpg</url>
	<title>protection Archives - Tech Chronicles</title>
	<link>https://kostacipo.stream/tag/protection/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>SSH Brute-force Protection With Fail2Ban</title>
		<link>http://kostacipo.stream/ssh-brute-force-protection-with-fail2ban/</link>
					<comments>http://kostacipo.stream/ssh-brute-force-protection-with-fail2ban/#respond</comments>
		
		<dc:creator><![CDATA[Majordomo]]></dc:creator>
		<pubDate>Fri, 03 Jan 2020 11:21:43 +0000</pubDate>
				<category><![CDATA[Cybersecurity]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[cybersecurity]]></category>
		<category><![CDATA[protection]]></category>
		<guid isPermaLink="false">http://www.kostacipo.stream/?p=1606</guid>

					<description><![CDATA[<p>&#160; Fail2Ban is an intrusion prevention framework written in Python that protects Linux systems and servers from brute-force attacks. We can setup Fail2Ban to provide brute-force protection for SSH on our server, this will ensure that the server is secure from brute-force attacks and it also allows us to monitor the strength of the brute-force [&#8230;]</p>
<p>The post <a href="http://kostacipo.stream/ssh-brute-force-protection-with-fail2ban/">SSH Brute-force Protection With Fail2Ban</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>
<div class="entry-content">
<p><iframe title="SSH Brute Force Protection With Fail2Ban" src="https://www.youtube.com/embed/Z0cDqF6HAxs?feature=oembed" allowfullscreen="allowfullscreen" data-mce-fragment="1" width="720" height="405" frameborder="0"></iframe></p>
<p>Fail2Ban is an intrusion prevention framework written in Python that protects Linux systems and servers from brute-force attacks. We can setup Fail2Ban to provide brute-force protection for SSH on our server, this will ensure that the server is secure from brute-force attacks and it also allows us to monitor the strength of the brute-force attacks in regards to the number of authentication attempts that are being made.</p>
<p>Brute-force attacks can be extremely powerful and may result in thousands of failed authentication attempts per day, it is therefore vital to understand how to protect your server from these attacks and how to block IP addresses. Fail2Ban allows us to automate the process of blocking brute-force attacks by limiting the number of failed authentication attempts a user can make before being blocked. This is extremely useful for servers that have user accounts that utilize passwords for remote authentication as opposed to SSH key-pair authentication.</p>
<h2>Installing And Configuring Fail2Ban</h2>
<p>Fail2Ban is free to use and can be installed through most of the popular package managers, in this case we are setting up Fail2Ban on Ubuntu server, so we can easily install Fail2Ban by running the following commands:</p>
<blockquote>
<p>sudo apt-get install fail2ban</p>
</blockquote>
<p>You should also ensure that Fail2ban runs on system startup, this can be done by using the following command:</p>
<blockquote>
<p>sudo systemctl enable fail2ban.service</p>
</blockquote>
<p>After the installation is complete we can begin configuring Fail2Ban to setup a jail for our SSH server.</p>
<p>After the installation is complete we can begin configuring Fail2Ban to setup a jail for our SSH server. The Fail2Ban configuration files are located in the <b><i>/etc/fail2ban</i></b> directory, as shown in image below.</p>
<p><img fetchpriority="high" decoding="async" class="alignnone  wp-image-5424" src="https://hsploit.com/wp-content/uploads/2019/11/fail2banetc-300x137.png" sizes="(max-width: 574px) 100vw, 574px" srcset="https://hsploit.com/wp-content/uploads/2019/11/fail2banetc-300x137.png 300w, https://hsploit.com/wp-content/uploads/2019/11/fail2banetc.png 600w" alt="" width="574" height="262"></p>
<p>Fail2Ban will use the default configuration in the <b><i>jail.conf</i></b> file, however it is not recommended to use the default configuration files as they can be overwritten by newer updates to the Fail2Ban package.</p>
<p>The preferred approach to creating configurations for a particular service is by creating a new configuration file in the<b><i> /etc/fail2ban</i></b> directory with the <b><i>.local</i></b> extension.&nbsp;</p>
<p>A Fail2ban jail is a configuration file that contains filters or arguments that protect your system or a particular service</p>
<h2>Creating SSH Jails With Fail2Ban</h2>
<p>We can begin by creating a new file within the same directory called jail.local, we can then add the necessary security configurations for the sshd jail.</p>
<blockquote>
<p>sudo nano /etc/fail2ban/jail.local</p>
</blockquote>
<p>We can explore the options that Fail2Ban provides to us to customize the security and blocking of the SSH service.</p>
<table>
<tbody>
<tr>
<td>
<h3><b>Configurations</b></h3>
</td>
<td>
<h3><b>Function</b></h3>
</td>
</tr>
<tr>
<td>enabled</td>
<td>Jail status (true/false) – This will enable or disable the jail</td>
</tr>
<tr>
<td>port</td>
<td>Port specification</td>
</tr>
<tr>
<td>filter</td>
<td>Service specific filter (Log filter)</td>
</tr>
<tr>
<td>logpath</td>
<td>What log to be used</td>
</tr>
<tr>
<td>maxretry</td>
<td>Number of attempts to be made before a ban</td>
</tr>
<tr>
<td>findtime</td>
<td>Amount of time between failed login attempts</td>
</tr>
<tr>
<td>bantime</td>
<td>Number of seconds an IP will be banned for</td>
</tr>
<tr>
<td>ignoreip</td>
<td>IP to be whitelisted</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>With the information in table above we can create a jail configuration for OpenSSH server (sshd), Once you have entered the configuration options the values we will be assigning are listed in the figure below.</p>
<p><img decoding="async" class="alignnone  wp-image-5425" src="https://hsploit.com/wp-content/uploads/2019/11/localjail-1.png" alt="" width="459" height="357"></p>
<p>After you have specified the configuration options you want to use and their respective values, we can save the file and restart the Fail2Ban service with the following command:</p>
<blockquote>
<p>sudo systemctl restart fail2ban.service</p>
</blockquote>
<h2>Testing Fail2Ban</h2>
<p>We can easily test this by attempting to login to the server&nbsp;with an incorrect password 3 times, after which we will be blocked from authentication for an hour.&nbsp;</p>
<p><img loading="lazy" decoding="async" class="alignnone  wp-image-5426" src="https://hsploit.com/wp-content/uploads/2019/11/fail2baninaction-300x142.png" sizes="auto, (max-width: 554px) 100vw, 554px" srcset="https://hsploit.com/wp-content/uploads/2019/11/fail2baninaction-300x142.png 300w, https://hsploit.com/wp-content/uploads/2019/11/fail2baninaction.png 531w" alt="" width="554" height="262"></p>
<p>As you can see in image above, after 3 consecutive failed attempts, Fail2Ban kicks in and actively blocks the SSH connection, after which the connection will timeout and the user will blocked for the specified time. If we try connecting again within the period in which we have been blocked, we can see that we get a “Connection refused” error and we are not able to establish an SSH connection to the server.</p>
<p>This demonstrates the power and robust nature of Fail2Ban and how it can be used to create elegant and effective firewalls for services like SSH. You can customize your service jails to meet your security requirements and easily implement new configuration options.</p>
<p>After implementing and testing Fail2Ban we can now take a look at how to monitor and analyze the various failed authentication attempts and blocked IP’s with the Fail2Ban-client.</p>
<h2>Monitoring With Fail2Ban-Client</h2>
<p>One of the greatest advantages of using Fail2Ban is that it allows us to actively monitor all the failed authentication attempts and the various IP addresses that have been blocked so far. This information is extremely helpful as it can help us understand the scale of attacks we are facing and the geolocation of the attacks by analyzing the origins of the IP addresses.</p>
<p>We can use the Fail2Ban-client tool to check the status of Fail2Ban and the active jails, this can&nbsp; be done by running the following command:</p>
<blockquote>
<p>sudo fail2ban-client status</p>
</blockquote>
<p><img loading="lazy" decoding="async" class="alignnone  wp-image-5427" src="https://hsploit.com/wp-content/uploads/2019/11/fail2banstatus-300x81.png" sizes="auto, (max-width: 478px) 100vw, 478px" srcset="https://hsploit.com/wp-content/uploads/2019/11/fail2banstatus-300x81.png 300w, https://hsploit.com/wp-content/uploads/2019/11/fail2banstatus.png 432w" alt="" width="478" height="129"></p>
<p>As shown in the image above, the active jail list is displayed with the names of the respective jails, in our case we can see that the sshd jail is active.</p>
<p>To view the status and information regarding a particular jail like sshd, we use the following command:</p>
<blockquote>
<p>sudo fail2ban-client status sshd</p>
</blockquote>
<p><img loading="lazy" decoding="async" class="alignnone  wp-image-5428" src="https://hsploit.com/wp-content/uploads/2019/11/fail2bansshdstatus-300x125.png" sizes="auto, (max-width: 490px) 100vw, 490px" srcset="https://hsploit.com/wp-content/uploads/2019/11/fail2bansshdstatus-300x125.png 300w, https://hsploit.com/wp-content/uploads/2019/11/fail2bansshdstatus.png 479w" alt="" width="490" height="204"></p>
<p>The image above shows us the status and information regarding the sshd jail, we can see that we have 4 total failed authentication attempts and one banned IP address. This is extremely helpful as it can alert you to potential targeted attacks.</p>
</div>
<p>The post <a href="http://kostacipo.stream/ssh-brute-force-protection-with-fail2ban/">SSH Brute-force Protection With Fail2Ban</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://kostacipo.stream/ssh-brute-force-protection-with-fail2ban/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
