良许Linux教程网 干货合集 centOs下DenyHosts的安装和使用方法

centOs下DenyHosts的安装和使用方法

DenyHosts是Python语言写的一个程序,它会分析sshd的日志文件(/var/log/secure),当发现重 复的攻击时就会记录IP到/etc/hosts.deny文件,从而达到自动屏IP的功能,下面为大家分享一下centOs下DenyHosts的安装和使用方法。

Centos7使用DenyHosts防止ssh暴力破解Centos7使用DenyHosts防止ssh暴力破解

下载DenyHosts包

[root@localhost ~]# wget http://jaist.dl.sourceforge.net/project/denyhosts/denyhosts/2.6/DenyHosts-2.6.tar.gz

安装DenyHosts

[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” Centos7使用DenyHosts防止ssh暴力破解Centos7使用DenyHosts防止ssh暴力破解

启动

[root@localhost DenyHosts-2.6]# ./daemon-control start(注意相对路径)

测试另外一台服务器远程连接172.16.1.16

默认允许五次,测试发现登陆失败五次之后不允许登陆

[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文件 Centos7使用DenyHosts防止ssh暴力破解Centos7使用DenyHosts防止ssh暴力破解 172.16.1.112的ip已经被限制,到此功能实现。

以上就是良许教程网为各位朋友分享的Linux系统相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多干货等着你 !

img
本文由 良许Linux教程网 发布,可自由转载、引用,但需署名作者且注明文章出处。如转载至微信公众号,请在文末添加作者公众号二维码。
良许

作者: 良许

良许,世界500强企业Linux开发工程师,公众号【良许Linux】的作者,全网拥有超30W粉丝。个人标签:创业者,CSDN学院讲师,副业达人,流量玩家,摄影爱好者。
上一篇
下一篇

发表评论

联系我们

联系我们

公众号:良许Linux

在线咨询: QQ交谈

邮箱: yychuyu@163.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部