1. 安装:

yum update -y

yum install fail2ban -y

2. 复制配置文件

cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

3. 编辑配置文件:

   vi /etc/fail2ban/jail.conf

上面是我找的相关配置。配置上即可

4. 启动

  systemctl start fail2ban

  # 开机自启

systemctl enable fail2ban

5. 查看日志:

   tail -10f  /var/log/fail2ban.log

6. 查看状态:

   fail2ban-client status sshd

7. 解封,手动封禁命令:

#封禁   非常烦的在那爆破机器

fail2ban-client set sshd banip  104.244.18.32

#解禁

fail2ban-client set sshd unbanip 104.244.18.32

Logo

码道开发者社区,聚焦华为云码道 CodeArts 代码智能体,沉淀 Agent、Skill、鸿蒙开发实战内容,供开发者查阅资料、交流技术、分享工程实践

更多推荐