fail2ban防止ssh暴力破解

测试环境

Red Hat Enterprise Linux Server release 6.3 (Santiago)

解压安装

tar zxvf fail2ban-0.9.6.tar.gz

cd fail2ban-0.9.6

/usr/bin/python setup.py install

安装服务、开机启动

cp files/redhat-initd /etc/init.d/fail2ban

chkconfig –add fail2ban

chkconfig fail2ban on

修改配置

cd /etc/fail2ban

cp paths-fedora.conf paths-rh.conf

vi paths-rh.conf

    # 注释掉这一行,系统不支持systemd
    #sshd_backend = systemd

cp jail.conf jail.conf.bak

vi jail.conf

    # 修改[INCLUDES]中这一行
    before = paths-rh.conf

    # 开启sshd防护,增加一行enabled=true
    [sshd]

    port    = ssh
    logpath = %(sshd_log)s
    backend = %(sshd_backend)s
    enabled = true    # 开启防护
    maxretry = 10    # 默认5次有点少,3次密码输入错误就封了

cp action.d/iptables-common.conf action.d/iptables-common.conf.bak

vi action.d/iptables-common.conf

    # iptables版本低参数不支持,删除lockingopt 的 -w
    lockingopt = 

启动服务

service fail2ban restart

查看启动状态

service fail2ban status

Status
|- Number of jail:    1
`- Jail list:    sshd
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值