centOs下DenyHosts的安装和使用方法

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

下载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”

启动

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

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

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

[root@localhost ~]# ssh [email protected]
[email protected]'s password: Permission denied, please try again. [email protected]'s password:
Permission denied, please try again.
[email protected]'s password: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). [root@localhost ~]# [root@localhost ~]# ssh [email protected] [email protected]'s password:
Permission denied, please try again.
[email protected]'s password: Permission denied, please try again. [email protected]'s password:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
[root@localhost ~]# ssh [email protected]
[email protected]'s password: Permission denied, please try again. [email protected]'s password:
Permission denied, please try again.
[email protected]'s password: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). [root@localhost ~]# ssh [email protected] [email protected]'s password:
Permission denied, please try again.
[email protected]'s password: Permission denied, please try again. [email protected]'s password:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
[root@localhost ~]# ssh [email protected]
ssh_exchange_identification: read: Connection reset by peer

查看hosts.deny文件

登陆连续失败之后就会把ip地址写在hosts.deny文件 172.16.1.112的ip已经被限制,到此功能实现。

原创文章,作者:晴川运维,如若转载,请注明出处:https://baike.qcidc.com/4536.html

(0)
晴川运维晴川运维
上一篇 2025年6月8日
下一篇 2025年6月8日

相关推荐

  • CentOS 7下面配置静态IP

    关于虚拟机 Linux设置 这里首先是进入/etc/sysconfig/network-scripts中查看现有的配置文件: # cd /etc/sysconfig/network…

    CentOS 2025年6月8日
  • CentOS 7下Redis5集群的搭建和使用

    1、简要说明 Redis5.0版是Redis产品的重大版本发布,推出了各种新特性,其中一点是放弃 Ruby的集群方式,改为 使用 C语言编写的 redis-cli的方式,是集群的构…

    CentOS 2025年6月24日
  • Linux系统之TroubleShooting(CentOS启动故障排除)

    尽管linux系统非常强大,稳定,但是我们在使用过程当中,如果人为操作不当,仍然会影响系统,甚至可能使得系统无法开机,无法运行服务等等各种问题。那么这篇博文就总结一下一些常见的故障…

    CentOS 2025年6月8日
  • CentOS 6.9 minimal版系统安装图形化界面

    有时我们会用到图形化界面来操作,下面介绍是在虚拟机上安装centos 6.9 minimal版安装图形化界面(其他系统版本都类似吧,,,),如果是在物理机上安装进入的话要用的远程桌…

    CentOS 2025年6月13日
  • CentOS7.2最小化安装配置Node.js环境

    安装一个新的Oracle VM VirtualBox测试来跑Node.js程序,以下为 centos7.2 最小化安装 初学者配置环境的过程,希望对初学者有所帮助,高手略过。 1:…

    CentOS 2025年6月17日
  • CentOS 7 网络连接优先由与无线问题解决

    该解决方法不具有一般性: 由于我安装centos 7系统时选择的是服务器模式而不是家用个人计算机之类的模式,网络配置阶段,有线禁用了dhcp协议,也没有无线相关的内容,于是在gno…

    CentOS 2025年6月12日
  • CentOS6中源码安装libvirt的问题

    libvirt是一套免费、开源的支持linux下主流虚拟化工具的C函数库,其旨在为包括Xen在内的各种虚拟化工具提供一套方便、可靠的编程接口,支持与C,C++,Ruby,Pytho…

    CentOS 2025年6月19日
  • CentOS 7.4部署MariaDB Galera Cluster集群架构

    Mariadb galera Cluster安装:操作系统:centos 7.4版本集群数量:3个节点主机信息: 192.168.153.142 node1 selinux=dis…

    CentOS 2025年6月11日
  • CentOS 7安装 MySQL5.7.19

    环境:虚拟机+centos 7 1.下载二进制包,下面mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz链接是官网 cd /usr/lo…

    CentOS 2025年7月10日
  • CentOS6.5下创建软RAID1

    什么是RAID 独立硬盘冗余阵列(RAID, Redundant Array of Independent Disks),旧称廉价磁盘冗余阵列(Redundant Array of…

    CentOS 2025年6月8日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注