Skip to content

通过知识获得解放,通过技术获得自由

Menu
  • 专题目录
  • 液压相关
    • 液压技术
    • 液压相邻技术
    • 液压应用
  • 计算机相关
    • 计算机和软件
    • 网络和网站技术
  • 哲学
  • 关于本站
Menu

centos7 fail2ban的安装和设置[0]

Posted on 2023年11月14日 by

  • fail2ban的安装
yum install epel-release
yum install fail2ban fail2ban-systemd
  • fail2ban的配置

复制配置文件 jail.local

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

查看jail.local

nano /etc/fail2ban/jail.local

创建一个新文件

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

添加如下内容:最长用的是ssh的22端口的防止暴力破解

[sshd]
enabled = true
port = ssh
action = firewallcmd-ipset
logpath = %(sshd_log)s
maxretry = 5
bantime = 86400

  • 启动fail2ban服务
systemctl enable fail2ban //设置成系统服务 
systemctl start fail2ban //安装完成之后,启用Fail2ban 
systemctl restart fail2ban 
systemctl status fail2ban //查询fail2ban的软件运行状态
systemctl restart firewalld
fail2ban-client status //查询fail2ban服务状态 
fail2ban-client status sshd //查询某个jail的详细信息
  • 查看fail2ban日志的日志

 

cat /var/log/secure | grep 'Failed password' //检查是否通过ssh端口尝试登录服务器失败
fail2ban-client set sshd unbanip 1.1.1.1 //删除某个被ban的ip

参考资料:

  1. https://www.lizenghai.com/archives/19150.html
  2. http://www.vpswe.com/linux/699.html
  3. https://xmyunwei.com/1612.html
  4. https://www.tecmint.com/install-fail2ban-to-protect-ssh-on-centos-rhel/

欢迎回来

希望本站对你有所帮助!

如有疑问请联系info@fanlog.org
2023 年 11 月
一二三四五六日
 12345
6789101112
13141516171819
20212223242526
27282930 
« 6 月    

AI辅助 (17)

© 2025 | Powered by Superbs Personal Blog theme
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT