<?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>深度VPS &#187; 攻击</title>
	<atom:link href="http://www.deepvps.com/tag/%E6%94%BB%E5%87%BB/feed" rel="self" type="application/rss+xml" />
	<link>http://www.deepvps.com</link>
	<description>专注VPS技术，关注前端技术</description>
	<lastBuildDate>Sat, 04 Feb 2023 14:00:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>使用DenyHosts阻止ssh暴力攻击</title>
		<link>http://www.deepvps.com/install-denyhosts.html</link>
		<comments>http://www.deepvps.com/install-denyhosts.html#comments</comments>
		<pubDate>Tue, 29 Mar 2011 05:34:12 +0000</pubDate>
		<dc:creator>deepvps</dc:creator>
				<category><![CDATA[VPS管理维护]]></category>
		<category><![CDATA[DenyHosts]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[攻击]]></category>
		<category><![CDATA[暴力]]></category>
		<category><![CDATA[暴力破解]]></category>

		<guid isPermaLink="false">http://www.deepvps.com/?p=756</guid>
		<description><![CDATA[现在的互联网非常不安全，很多人没事就拿一些扫描机扫描ssh端口，然后试图连接ssh端口进行暴力破解（穷举扫描），所以建议大家VPS尽量设置复杂的ssh登录密码。那么有什么办法阻止这些暴力破解者呢，我们可以使用DenyHosts这款软件。
DenyHosts介绍
DenyHosts是Python语言写的一个程序，它会分析sshd的日志文件（/var/log/secure），当发现重 复的攻击时就会记录IP到/etc/hosts.deny文件，从而达到自动屏IP的功能。
DenyHosts安装和配置
1、下载和安装EPEL RPM
cd /tmp
wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
rpm -Uhv epel-release-5-3.noarch.rpm
2、使用yum命令安装denyhosts
yum install -y denyhosts

3、添加系统启动自动运行
chkconfig --add denyhosts
chkconfig denyhosts on
如何你想把某个ip或者ip段放入白名单，可以使用下列命令，这样就可以避免把自己的ip阻止了；
echo '173.252.193.*' &#62;&#62; /var/lib/denyhosts/allowed-hosts
这样 173.252.193.* 这个IP就可以不受到此程序的约束，请根据自己的环境进行设置；
4、最后启动服务
service denyhosts start
设置完以上4步，DenyHosts就可以正常工作了。
附上：DenyHosts配置文件denyhosts.cfg说明
SECURE_LOG = /var/log/secure
 
#sshd日志文件，它是根据这个文件来判断的，不同的操作系统，文件名稍有不同。
 
HOSTS_DENY = /etc/hosts.deny
 
#控制用户登陆的文件
 
PURGE_DENY = 5m
 
#过多久后清除已经禁止的
 
BLOCK_SERVICE  = sshd
 
#禁止的服务名
 
DENY_THRESHOLD_INVALID = 1
 
#允许无效用户失败的次数
 
DENY_THRESHOLD_VALID = 10
 
#允许普通用户登陆失败的次数
 
DENY_THRESHOLD_ROOT = 5
 
#允许root登陆失败的次数
 
HOSTNAME_LOOKUP=NO
 
#是否做域名反解
 
DAEMON_LOG = /var/log/denyhosts
 
#DenyHosts的日志文件
]]></description>
			<content:encoded><![CDATA[<p>现在的互联网非常不安全，很多人没事就拿一些扫描机扫描ssh端口，然后试图连接ssh端口进行暴力破解（穷举扫描），所以建议大家VPS尽量设置复杂的ssh登录密码。那么有什么办法阻止这些暴力破解者呢，我们可以使用DenyHosts这款软件。</p>
<h3>DenyHosts介绍</h3>
<p>DenyHosts是Python语言写的一个程序，它会分析sshd的日志文件（/var/log/secure），当发现重 复的攻击时就会记录IP到/etc/hosts.deny文件，从而达到自动屏IP的功能。</p>
<h3>DenyHosts安装和配置</h3>
<p>1、下载和安装EPEL RPM</p>
<pre>cd /tmp
wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
rpm -Uhv epel-release-5-3.noarch.rpm</pre>
<p>2、使用yum命令安装denyhosts</p>
<pre>yum install -y denyhosts</pre>
<p><span id="more-756"></span><br />
3、添加系统启动自动运行</p>
<pre>chkconfig --add denyhosts
chkconfig denyhosts on</pre>
<p>如何你想把某个ip或者ip段放入白名单，可以使用下列命令，这样就可以避免把自己的ip阻止了；</p>
<pre>echo '173.252.193.*' &gt;&gt; /var/lib/denyhosts/allowed-hosts</pre>
<p>这样 173.252.193.* 这个IP就可以不受到此程序的约束，请根据自己的环境进行设置；<br />
4、最后启动服务</p>
<pre>service denyhosts start</pre>
<p>设置完以上4步，DenyHosts就可以正常工作了。</p>
<p>附上：DenyHosts配置文件denyhosts.cfg说明</p>
<blockquote><p>SECURE_LOG = /var/log/secure<br />
 <br />
#sshd日志文件，它是根据这个文件来判断的，不同的操作系统，文件名稍有不同。<br />
 <br />
HOSTS_DENY = /etc/hosts.deny<br />
 <br />
#控制用户登陆的文件<br />
 <br />
PURGE_DENY = 5m<br />
 <br />
#过多久后清除已经禁止的<br />
 <br />
BLOCK_SERVICE  = sshd<br />
 <br />
#禁止的服务名<br />
 <br />
DENY_THRESHOLD_INVALID = 1<br />
 <br />
#允许无效用户失败的次数<br />
 <br />
DENY_THRESHOLD_VALID = 10<br />
 <br />
#允许普通用户登陆失败的次数<br />
 <br />
DENY_THRESHOLD_ROOT = 5<br />
 <br />
#允许root登陆失败的次数<br />
 <br />
HOSTNAME_LOOKUP=NO<br />
 <br />
#是否做域名反解<br />
 <br />
DAEMON_LOG = /var/log/denyhosts<br />
 <br />
#DenyHosts的日志文件</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.deepvps.com/install-denyhosts.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
