Home >Computer Tutorials >Computer Knowledge >How to use Fail2ban to prevent brute force attacks on Linux?

How to use Fail2ban to prevent brute force attacks on Linux?

王林
王林forward
2024-02-21 18:34:23645browse

如何使用 Fail2ban 防止对 Linux 的暴力攻击?

Fail2ban is an open source security tool designed to protect Linux systems from brute force attacks, especially brute force cracking of SSH services. Here is how to use Fail2ban to enhance the security of your Linux system:

  1. Install Fail2ban:

    • Open a terminal and log in to the Linux system as an administrator.
    • Install Fail2ban using the package manager appropriate for your distribution (such as apt, yum, etc.).
  2. Configure Fail2ban:

    • Open the configuration file of Fail2ban and run the following command in the terminal:

      sudo vi /etc/fail2ban/jail.conf
    • In the configuration file, you can find settings for different services (such as SSH). Make sure to enable the appropriate services and make necessary adjustments, such as adjusting the maximum number of attempts, ban time, etc.
  3. Reload Fail2ban configuration:

    • Run the following command in the terminal to reload Fail2ban’s configuration:

      sudo systemctl restart fail2ban
  4. Monitor Fail2ban logs:

    • Fail2ban will log its activities and bans. You can use the following command to view Fail2ban logs:

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

Through the above steps, you can use Fail2ban to prevent brute force attacks on Linux systems. Fail2ban will monitor the system logs for login attempts and ban them based on configured rules. This can greatly reduce malicious users' brute force attempts and improve system security. Please note that before using Fail2ban, it is recommended to carefully read Fail2ban's documentation and configuration files to ensure that the settings are appropriately adjusted to meet your system needs.

The above is the detailed content of How to use Fail2ban to prevent brute force attacks on Linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:mryunwei.com. If there is any infringement, please contact admin@php.cn delete