Skip to content

fix #80 astra-linuxfail2ban #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions content/3.misc/1.tools-and-utilities/2.network/ail2ban.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: "Fail2ban: SSH protection"
date: 2023-03-02
---

Fail2Ban is a program that protects servers from bruteforce attacks. (attacks in which a hacker breaks the password to SSH or another service using brute force)

## Installation

```sh
bash <(wget -qO- https://cesbo.com/download/astra/scripts/fail2ban.sh)
```

First, the script will suggest changing the ssh port. For example: changing the port number from 22 to 8382 will make it harder for bots to detect ssh.
Next, you will be asked for the number of failed authorization attempts: (by default, 3)
The last question is how long in hours we will block the ip from which there were unsuccessful attempts to log in.
After that, the script will download, install, and configure the service.
The file /var/log/astra.log will also be monitored: if authorization attempts fail in the Astra web interface, the user will be blocked.
If you use a different log file name for astra, fix it in /etc/fail2ban/jail.local

The fail2ban configuration is complete.

## Use

Viewing statistics

```sh
fail2ban-client status
```

To unblock the ip, run the following command:

```sh
fail2ban-client set ssh-iptables unbanip IPADDRESS
```