其他分享
首页 > 其他分享> > 关于fail2ban防暴力破解总结

关于fail2ban防暴力破解总结

作者:互联网

为什么要用fail2ban

今天早上起来查看服务器日志,无意中发现了好多ip尝试破解我的密码,但是禁ip的可行性基本上为0,因为换ip对他们来说基本上就是有手就行。于是我便想到了fail2ban

这仅仅是一部分攻击我的ip

攻击ip截图

fail2ban的安装与配置

安装
  1. CentOS系统
yum install fail2ban
  1. Debian或Ubuntu系统
apt-get install fail2ban
配置

增加sshd的配置

vi /etc/fail2ban/jail.d/sshd.local

例如:

[ssh-iptables]
enabled  = true
filter   = sshd
action   = iptables[name=SSH, port=ssh, protocol=tcp]
logpath  = /var/log/secure
maxretry = 5   # 最多连接五次失败
bantime  = 604800   # 禁止7天(按秒计算)

如果是debianubuntu系统,logpath需要修改成/var/log/auth.log
保存这个文件。

启动

CentOS 7等使用systemctl方式启动

systemctl start fail2ban.service

老的init启动脚本方式的启动

service fail2ban start

或(我的是ubuntu,所以我用的是这条)

/etc/init.d/fail2ban start
检查

查看进程是否存在且防火墙是否生效。
查看配置是否生效
今天的文字就到此为止啦,有问题可以跟我讨论哦

标签:总结,sshd,暴力破解,log,启动,ip,start,fail2ban
来源: https://blog.csdn.net/weixin_44468853/article/details/113583192