<?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/"
	 xmlns:media="http://search.yahoo.com/mrss/" >

<channel>
	<title>DenyHosts &#8211; AnonyViet &#8211; English Version</title>
	<atom:link href="https://en.anonyviet.com/tag/denyhosts/feed/" rel="self" type="application/rss+xml" />
	<link>https://en.anonyviet.com</link>
	<description>The most popular website for sharing information technology, computer networks, and security knowledge. Stay up to date with the hottest news and tips</description>
	<lastBuildDate>Tue, 24 Jan 2023 12:20:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>

<image>
	<url>https://en.anonyviet.com/wp-content/uploads/2023/01/cropped-ico-logo-75x75-1.png</url>
	<title>DenyHosts &#8211; AnonyViet &#8211; English Version</title>
	<link>https://en.anonyviet.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Block Brute Force SSH with DenyHosts</title>
		<link>https://en.anonyviet.com/how-to-block-brute-force-ssh-with-denyhosts/</link>
					<comments>https://en.anonyviet.com/how-to-block-brute-force-ssh-with-denyhosts/#respond</comments>
		
		<dc:creator><![CDATA[AnonyViet]]></dc:creator>
		<pubDate>Tue, 24 Jan 2023 12:20:07 +0000</pubDate>
				<category><![CDATA[Network]]></category>
		<category><![CDATA[Block]]></category>
		<category><![CDATA[Brute]]></category>
		<category><![CDATA[DenyHosts]]></category>
		<category><![CDATA[Force]]></category>
		<category><![CDATA[SSH]]></category>
		<guid isPermaLink="false">https://en.anonyviet.com/?p=1792</guid>

					<description><![CDATA[DenyHosts is open source software that helps block brute force attacks with SSH login to help protect your Linux Server more securely. This is a fairly lightweight Tool and very simple to use, just exceed the number of incorrect logins, that IP will be blocked, unable to detect Key, Password SSH. Join the channel Telegram [&#8230;]]]></description>
										<content:encoded><![CDATA[<p></p>
<div id="ftwp-postcontent">
<p><strong><a target="_blank" href="https://en.anonyviet.com/next-link/?url=https%3A%2F%2Fgithub.com%2Fdenyhosts%2Fdenyhosts" rel="noopener external nofollow" class="ext-link" onclick="this.target='_blank';">DenyHosts</a> is open source software that helps block brute force attacks with SSH login to help protect your Linux Server more securely.  This is a fairly lightweight Tool and very simple to use, just exceed the number of incorrect logins, that IP will be blocked, unable to detect Key, Password SSH.</strong></p>
<div class="code-block code-block-16" style="margin: 8px 0; clear: both;">
<div align="center">
<table class=" aligncenter" style="background-color: #c0c0c0; border-collapse: collapse; width: 59.9985%;">
<tbody>
<tr>
<td style="width: 100%; text-align: center;"><span style="font-size: 12pt;"><strong>Join the channel <span style="color: #0000ff;">Telegram</span> of the <span style="color: #008080;">AnonyViet </span> 👉 <span style="text-decoration: underline;"><a target="_blank" href="https://en.anonyviet.com/next-link?url=https%3A%2F%2Ft.me%2Fanonyvietchat" class="local-link" rel="noopener">Link</a></span>  👈</strong></span></td>
</tr>
</tbody>
</table>
</div>
</div>
<p><img post-id="1792" fifu-featured="1" fetchpriority="high" decoding="async" class="aligncenter wp-image-38495 size-full" src="https://anonyviet.com/wp-content/uploads/2021/12/dt11.png" alt="How to Block Brute Force SSH with DenyHosts" title="How to Block Brute Force SSH with DenyHosts" width="838" height="644" srcset="https://anonyviet.com/wp-content/uploads/2021/12/dt11.png 838w, https://anonyviet.com/wp-content/uploads/2021/12/dt11-300x231.png 300w, https://anonyviet.com/wp-content/uploads/2021/12/dt11-768x590.png 768w, https://anonyviet.com/wp-content/uploads/2021/12/dt11-750x576.png 750w" sizes="(max-width: 838px) 100vw, 838px" title="How to Block Brute Force SSH with DenyHosts 6"/></p>
<p>DenyHosts monitors and analyzes SSH Logs for false logins, dictionary-based attacks, and attacks. <a target="_blank" href="https://en.anonyviet.com/next-link?url=https%3A%2F%2Fanonyviet.com%2Ftan-cong-brute-force-la-gi-va-cach-ngan-chan%2F" rel="noopener" class="local-link">brute force attack</a> by blocking the original IP addresses and adding an entry to the file <strong>/etc/hosts.deny</strong> on the server and prevent the IP address from making any further login attempts.</p>
<p>DenyHosts is a very essential tool for all Linux based systems, especially when we allow ssh login to remote Linux servers.</p>
<p>In this article, I will show you how to install and configure DenyHosts on RHEL-based Linux distributions like Fedora, CentOS, Rocky Linux, and AlmaLinux.</p>
<h2 id="ftoc-cach-cai-dat-denyhosts-trong-linux" class="ftwp-heading">How to Install DenyHosts in Linux</h2>
<p>By default, the DenyHosts tool is not built-in to the Linux system, we need to install it using a third-party EPEL repository.  After adding the repository, install the DenyHosts package using the following yum command.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic"># yum install epel-release&#13;
# yum install denyhosts</pre>
<h2 id="ftoc-cau-hinh-denyhosts-cho-cac-dia-chi-ip-trong-whitelist" class="ftwp-heading">Configure DenyHosts for IP addresses in Whitelist</h2>
<p>After installing Denyhosts, make sure to whitelist your own IP address, so that it never gets blocked.  To do this, open the file /etc/hosts.allow.</p>
<pre># vi /etc/hosts.allow</pre>
<p>Below the description, add each IP address in a separate line that you don&#8217;t want to block.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">#&#13;
# hosts.allow   This file contains access rules which are used to&#13;
#               allow or deny connections to network services that&#13;
#               either use the tcp_wrappers library or that have been&#13;
#               started through a tcp_wrappers-enabled xinetd.&#13;
#&#13;
#               See 'man 5 hosts_options' and 'man 5 hosts_access'&#13;
#               for information on rule syntax.&#13;
#               See 'man tcpd' for information on tcp_wrappers&#13;
#&#13;
sshd: 172.16.25.125&#13;
sshd: 172.16.25.126&#13;
sshd: 172.16.25.127</pre>
<h2 id="ftoc-cau-hinh-denyhosts-cho-cac-canh-bao-qua-email" class="ftwp-heading">Configure DenyHosts for email alerts</h2>
<p>The main configuration file is located in /etc/denyhosts.conf.  This file is used to send email notifications about suspected logins.  Open this file with an editor <code>vi</code>.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic"># vi /etc/denyhosts.conf</pre>
<p>Find the line &#8216;ADMIN_EMAIL&#8217; and add your email address here to receive email notifications of suspicious logins (for multiple emails, use commas).  Each variable is fully documented so configure it to your liking.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">############ DENYHOSTS REQUIRED SETTINGS ############&#13;
SECURE_LOG = /var/log/secure&#13;
HOSTS_DENY = /etc/hosts.deny&#13;
BLOCK_SERVICE  = sshd&#13;
DENY_THRESHOLD_INVALID = 5&#13;
DENY_THRESHOLD_VALID = 10&#13;
DENY_THRESHOLD_ROOT = 1&#13;
DENY_THRESHOLD_RESTRICTED = 1&#13;
WORK_DIR = /var/lib/denyhosts&#13;
SUSPICIOUS_LOGIN_REPORT_ALLOWED_HOSTS=YES&#13;
HOSTNAME_LOOKUP=YES&#13;
LOCK_FILE = /var/lock/subsys/denyhosts&#13;
&#13;
############ DENYHOSTS OPTIONAL SETTINGS ############&#13;
ADMIN_EMAIL = ravisaive@tecmint.com&#13;
SMTP_HOST = localhost&#13;
SMTP_PORT = 25&#13;
SMTP_FROM = DenyHosts &lt;tecmint@tecmint.com&gt;&#13;
SMTP_SUBJECT = DenyHosts Daily Report&#13;
&#13;
############ DENYHOSTS OPTIONAL SETTINGS ############&#13;
DAEMON_LOG = /var/log/denyhosts&#13;
DAEMON_SLEEP = 30s&#13;
DAEMON_PURGE = 1h</pre>
<h2 id="ftoc-khoi-dong-lai-dich-vu-denyhosts" class="ftwp-heading">Restart the DenyHosts service</h2>
<p>When you&#8217;re done with the configuration, reboot <strong>denyhosts</strong>.  We also add <strong>denyhosts</strong> into startup.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic"># chkconfig denyhosts on&#13;
# service denyhosts start</pre>
<h2 id="ftoc-xem-nhat-ky-denyhosts" class="ftwp-heading">View DenyHosts logs</h2>
<p>To view the diary <strong>denyhosts</strong> how many attackers and hackers are trying to access your server.  Please use the following command:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic"># tail -f /var/log/secure</pre>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">Nov 28 15:01:43 tecmint sshd[25474]: Accepted password for root from 172.16.25.125 port 4339 ssh2&#13;
Nov 28 15:01:43 tecmint sshd[25474]: pam_unix(sshd:session): session opened for user root by (uid=0)&#13;
Nov 28 16:44:09 tecmint sshd[25474]: pam_unix(sshd:session): session closed for user root&#13;
Nov 29 11:08:56 tecmint sshd[31669]: Accepted password for root from 172.16.25.125 port 2957 ssh2&#13;
Nov 29 11:08:56 tecmint sshd[31669]: pam_unix(sshd:session): session opened for user root by (uid=0)&#13;
Nov 29 11:12:00 tecmint atd[3417]: pam_unix(atd:session): session opened for user root by (uid=0)&#13;
Nov 29 11:12:00 tecmint atd[3417]: pam_unix(atd:session): session closed for user root&#13;
Nov 29 11:26:42 tecmint sshd[31669]: pam_unix(sshd:session): session closed for user root&#13;
Nov 29 12:54:17 tecmint sshd[7480]: Accepted password for root from 172.16.25.125 port 1787 ssh2</pre>
<h2 id="ftoc-xoa-dia-chi-ip-bi-chan-khoi-denyhosts" class="ftwp-heading">Remove blocked IP address from DenyHosts</h2>
<p>If you want to remove that blocked IP address from <strong>denyhosts</strong>.  You need to stop the tool.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic"># /etc/init.d/denyhosts stop</pre>
<p>To remove or completely remove blocked IP address.  You need to edit the following files and remove the IP address.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic"># vi /etc/hosts.deny&#13;
# vi /var/lib/denyhosts/hosts&#13;
# vi /var/lib/denyhosts/hosts-restricted&#13;
# vi /var/lib/denyhosts/hosts-root&#13;
# vi /var/lib/denyhosts/hosts-valid&#13;
# vi /var/lib/denyhosts/users-hosts</pre>
<p>After removing the blocked IP address, restart the service.</p>
<pre># /etc/init.d/denyhosts start</pre>
<p>The offending IP address has been added to all files in the directory <strong>/var/lib/denyhosts</strong>, so it is difficult to determine which file contains the offending IP address.  One of the best ways to find out the IP address is to use the grep command.  Example to find out IP address 172.16.25.125:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">cd /var/lib/denyhosts&#13;
grep 172.16.25.125 *</pre>
<h2 id="ftoc-whitelist-dia-chi-ip-vinh-vien-trong-denyhosts" class="ftwp-heading">Permanently whitelist IP addresses in DenyHosts</h2>
<p>If you have a list of static IP addresses that you want to whitelist permanently.  Please open the file  <strong>/var/lib/denyhosts/allowed-hosts</strong>.  Any IP addresses contained in this file will not be blocked by default.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic"># vi /var/lib/denyhosts/allowed-hosts</pre>
<p>And add each IP address on each line separately.  Then save and close the file.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic"># We mustn't block localhost&#13;
127.0.0.1&#13;
172.16.25.125&#13;
172.16.25.126&#13;
172.16.25.127</pre>
<div class="kk-star-ratings kksr-auto kksr-align-right kksr-valign-bottom" data-payload="{&quot;align&quot;:&quot;right&quot;,&quot;id&quot;:&quot;38490&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;bottom&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;100&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;5&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;\u0110\u00e1nh gi\u00e1 b\u00e0i vi\u1ebft post&quot;,&quot;legend&quot;:&quot;B\u00e0i vi\u1ebft \u0111\u1ea1t: 5\/5 - (100 b\u00ecnh ch\u1ecdn)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;width&quot;:&quot;142.5&quot;,&quot;_legend&quot;:&quot;B\u00e0i vi\u1ebft \u0111\u1ea1t: {score}\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}">
<p>            The article achieved: 5/5 &#8211; (100 votes)    </p>
</p></div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://en.anonyviet.com/how-to-block-brute-force-ssh-with-denyhosts/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<media:content url="https://anonyviet.com/wp-content/uploads/2021/12/dt11.png" medium="image"></media:content>
            	</item>
	</channel>
</rss>
