<?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>Linux Admin Zone &#187; DenyHost</title>
	<atom:link href="http://linuxadminzone.com/tag/denyhost/feed/" rel="self" type="application/rss+xml" />
	<link>http://linuxadminzone.com</link>
	<description>Adding more reasons to celebrate Open Source.</description>
	<lastBuildDate>Wed, 09 May 2012 10:17:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Install and configure DenyHost</title>
		<link>http://linuxadminzone.com/install-and-configure-denyhost/</link>
		<comments>http://linuxadminzone.com/install-and-configure-denyhost/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 13:24:56 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[DenyHost]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=5</guid>
		<description><![CDATA[Brute force attacks or dictionary based attacks are common these days for servers. DenyHosts is an excellent python tool to prevent such attacks. It will detects failed attempts and prevent offending Host/IP for further connection by adding it to /etc/hosts.deny file. Here are steps to install and configure DenyHosts for your server. These steps are [...]]]></description>
			<content:encoded><![CDATA[<p>Brute force attacks or dictionary based attacks are common these days for servers. DenyHosts is an excellent python tool to prevent such attacks. It will detects failed attempts and prevent offending Host/IP for further connection by adding it to <strong>/etc/hosts.deny</strong> file.</p>
<p>Here are steps to install and configure DenyHosts for your server. These steps are applicable for Red Hat based distros (ie RHEL, CentOS, Fedora) and needs minor changes for other distros. You can copy paste the commands.</p>
<p><strong>Step 1.</strong> Detect which version of Python is installed on your server:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># python -V</span></pre></div></div>

<p><strong>Step 2.</strong> You will see python version 2.3.x (for CentOS 4.x) or 2.4.x (,CentOS 5.x, Fedora etc). Download the relevant rpm from <a href="http://sourceforge.net/project/showfiles.php?group_id=131204">sourceforge</a> or source tarball, I have download it by using this direct <a href="wget http://downloads.sourceforge.net/project/denyhosts/denyhosts/2.6/DenyHosts-2.6.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fdenyhosts%2Ffiles%2F&#038;ts=1297618714&#038;use_mirror=space">link</a>.</p>
<p><strong>Step 3.</strong> Install the rpm:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># rpm -ivh DenyHosts-2.6-python2.3.noarch.rpm</span></pre></div></div>

<p>or compile and install from tarball, you have it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># tar xzf DenyHosts-2.6.tar.gz</span>
<span style="color: #666666; font-style: italic;"># cd DenyHosts-2.6 </span>
<span style="color: #666666; font-style: italic;"># python setup.py install</span></pre></div></div>

<p><strong>Step 4.</strong> make a copy of default configuration file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># cd /usr/share/denyhosts/</span>
<span style="color: #666666; font-style: italic;"># cp denyhosts.cfg-dist denyhosts.cfg</span></pre></div></div>

<p><strong>Step 5.</strong> Edit the configuration file to suit your needs:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># vi denyhosts.cfg</span></pre></div></div>

<p><strong>Step 6.</strong> You can run DenyHosts by cron or as Daemon. preferred way is to run it as daemon. To run it as daemon, make a copy of its default daemon script</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># cp daemon-control-dist daemon-control</span></pre></div></div>

<p><strong>Step 7.</strong> Set proper permissions for daemon script:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># chown root daemon-control</span>
<span style="color: #666666; font-style: italic;"># chmod 700 daemon-control</span></pre></div></div>

<p><strong>Step 8.</strong> Start it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># ./daemon-control start</span></pre></div></div>

<p><strong>Step 9.</strong> Make it run on startup:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># cd /etc/init.d</span>
<span style="color: #666666; font-style: italic;"># ln -s /usr/share/denyhosts/daemon-control denyhosts</span>
<span style="color: #666666; font-style: italic;"># chkconfig -–add denyhosts</span></pre></div></div>

<p><strong>Step 10.</strong> You can view its log and also view the hosts.deny file to find out how many hosts are denied:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># tail /var/log/denyhosts</span>
<span style="color: #666666; font-style: italic;"># cat /etc/hosts.deny</span></pre></div></div>

<p>One other way to prevent such attacks is to use tcpwrappers and allow services (ssh) from specific IP Addresses only.</p>
<p>More related and helpful articles:<br />
* <a href="http://linuxadminzone.com/5-steps-to-secure-your-linux-server/"> 5 steps to secure your Linux Server </a><br />
* <a href="http://linuxadminzone.com/ensuring-secure-access-to-production-linux-servers/"> Ensuring secure access to production Linux Servers </a><br />
* <a href="http://linuxadminzone.com/bash-script-to-backup-essential-log-files-of-linux-server/"> Bash script to backup essential log files in Linux </a><br />
* <a href="http://linuxadminzone.com/quickly-change-your-ssh-port-from-default-22-to-something-higher/"> Quickly change your ssh port from defualt 22 to something higher </a><br />
* <a href="http://linuxadminzone.com/ssh-port-forwarding-from-remote-to-local-machine/"> SSH port forwarding from remote to local machine </a><br />
* <a href="http://linuxadminzone.com/save-root-or-user-history-to-check-later/"> Save root or user history to check later </a> </p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/install-and-configure-denyhost/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

