CentOS 7 防暴力破解 Fail2ban

CentOS 7 fail2ban 防暴力破解
使用 yum 安装 fail2ban

先安装 epel

yum -y install epel-release
Bash
安装 fail2ban

yum -y install fail2ban
Bash
启动服务

systemctl enable fail2ban
systemctl start fail2ban
Bash
查看版本

fail2ban-client -V
Fail2Ban v0.9.7

Copyright © 2004-2008 Cyril Jaquier, 2008- Fail2Ban Contributors
Copyright of modifications held by their respective authors.
Licensed under the GNU General Public License v2 (GPL).

Written by Cyril Jaquier cyril.jaquier@fail2ban.org.
Many contributions by Yaroslav O. Halchenko
Bash
修改配置文件

vim /etc/fail2ban/jail.conf
Bash
在末尾添加

[ssh-iptables]
enabled = true
filter = sshd
action = iptables[name=SSH, port=ssh, protocol=tcp]
#sendmail-whois[name=SSH,dest=your@email.com,sender=fail2ban@email.com]
logpath = /var/log/secure
maxretry = 3
bantime = 300
Bash
重启服务

systemctl restart fail2ban
Bash
在其他服务器

ssh root@172.16.231.144
Bash
故意输入三次错误密码后提示

ssh: connect to host 172.16.231.144 : Connection refused
Bash
在 fail2ban 服务器中查看

fail2ban-client status ssh-iptables
Bash
显示如下,发现已经添加了规则,

Status for the jail: ssh-iptables
|- Filter
| |- Currently failed: 0
| |- Total failed: 6
| - File list: /var/log/secure- Actions
|- Currently banned: 1
|- Total banned: 2
`- Banned IP list: 172.16.231.144

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值