您的位置:首页 > 其它

DenyHosts阻止SSH暴力破解

2012-11-12 12:29 483 查看
在/var/log/secure文件中,发现经常有人在试图破解登录密码,在网上找到了这个denyhosts工具,个人也测试了,感觉还是挺不错的。现把安装步骤贡献出来,也为了以后查询。
安装环境:centos5.5 x86

1.下载并解压DenyHosts源码包
[root@www ~]#wget http://sourceforge.net/projects/denyhosts/files/denyhosts/2.6/DenyHosts-2.6.tar.gz [root@www ~]#tar zxvf DenyHosts-2.6.tar.gz
[root@www ~]#cd DenyHosts-2.6
[root@www DenyHosts-2.6]#python setup.py install
2.开始安装
[root@www DenyHosts-2.6]#cd /usr/share/denyhosts/
[root@www denyhosts]#cp daemon-control-dist daemon-control
[root@www denyhosts]#chown root daemon-control
[root@www denyhosts]#chmod 700 daemon-control
[root@www denyhosts]#grep -v "^#" denyhosts.cfg-dist > denyhosts.cfg
3.编辑配置文件
[root@www denyhosts]#vi denyhosts.cfg
SECURE_LOG = /var/log/secure

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

#是否做域名反解

[root@www denyhosts]#cd /etc/init.d/
[root@www init.d]#ln -s /usr/share/denyhosts/daemon-control denyhosts
[root@www init.d]#chkconfig --add denyhosts
[root@www init.d]#chkconfig --level 345 denyhosts on
[root@www init.d]#/etc/init.d/denyhosts restart

echo "/usr/share/denyhosts/daemon-control start" >> /etc/rc.local
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: