DenyHosts是Python语言写的一个程序,它会分析sshd的日志文件(/var/log/secure),当发现重 复的攻击时就会记录IP到/etc/hosts.deny文件,从而达到自动屏IP的功能,下面为大家分享一下centOs下DenyHosts的安装和使用方法。
[root@localhost ~]# wget http://jaist.dl.sourceforge.net/project/denyhosts/denyhosts/2.6/DenyHosts-2.6.tar.gz
[root@localhost ~]# tar xf DenyHosts-2.6.tar.gz
[root@localhost ~]# cd DenyHosts-2.6
[root@localhost DenyHosts-2.6]# python setup.py install
[root@localhost DenyHosts-2.6]# cp denyhosts.cfg-dist /etc/denyhosts.cfg
[root@localhost DenyHosts-2.6]# cp daemon-control-dist daemon-control
[root@localhost DenyHosts-2.6]# chown root daemon-control
[root@localhost DenyHosts-2.6]# chmod 700 daemon-control
将daemon-control中的#DENYHOSTS_CFG = “/usr/share/denyhosts/denyhosts.cfg”改为 DENYHOSTS_CFG = “/etc/denyhosts.cfg”
启动
[root@localhost DenyHosts-2.6]# ./daemon-control start(注意相对路径)
默认允许五次,测试发现登陆失败五次之后不允许登陆
[root@localhost ~]# ssh abc@172.16.1.16
abc@172.16.1.16's password: Permission denied, please try again. abc@172.16.1.16's password:
Permission denied, please try again.
abc@172.16.1.16's password: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). [root@localhost ~]# [root@localhost ~]# ssh abc@172.16.1.16 abc@172.16.1.16's password:
Permission denied, please try again.
abc@172.16.1.16's password: Permission denied, please try again. abc@172.16.1.16's password:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
[root@localhost ~]# ssh abc@172.16.1.16
abc@172.16.1.16's password: Permission denied, please try again. abc@172.16.1.16's password:
Permission denied, please try again.
abc@172.16.1.16's password: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). [root@localhost ~]# ssh abc@172.16.1.16 abc@172.16.1.16's password:
Permission denied, please try again.
abc@172.16.1.16's password: Permission denied, please try again. abc@172.16.1.16's password:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
[root@localhost ~]# ssh abc@172.16.1.16
ssh_exchange_identification: read: Connection reset by peer
查看hosts.deny文件
登陆连续失败之后就会把ip地址写在hosts.deny文件 172.16.1.112的ip已经被限制,到此功能实现。
本文名称:centOs下DenyHosts的安装和使用方法
当前URL:http://www.shufengxianlan.com/qtweb/news49/347949.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联