Skip to content

Setup fail2ban to cover wings.md #468

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 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
66 changes: 66 additions & 0 deletions community/Wings Fail2ban Setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Fail2ban wings configuration

Fail2ban is a program that works with iptables to better secure your server and services from brute force login attempts

### Step 1: if you havent already Using your preferred package manager
(to my best knowledge, iptables will come with fail2ban when you install it, but if not install that too)

`apt-get install fail2ban`

### Step 2: After you install Fail2Ban Copy some files, If you already have local files, skip these steps
#### We have to copy .conf to .local files, as .conf may be wiped with updates. Local files will persist

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

### Step 3 Copy some text into the new local files using your favorite text editor, here we're going to be using nano

`nano /etc/fail2ban/jail.local`

scroll down until you see the actual jail portion of the file, input this text below the [SSHD] block, save it and exit

[wings]
enabled = true
port = 2022
logpath = /var/log/pterodactyl/wings.log
maxretry = 4
findtime = 3600
bantime = -1
backend = systemd


### Step 4: Create the filter file and copy some more text

`cd /etc/fail2ban/conf.d/`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By my side, on Ubuntu 22.04 and Fail2ban 0.11.2-6, the filter file comes into /etc/fail2ban/filter.d/
https://help.ubuntu.com/community/Fail2ban

`touch wings.conf`
`nano wings.conf`

Copy this text into the newly created file, Save then exit

# Fail2Ban filter for wings (Pterodactyl daemon)
#
#
#
# "WARN: [Sep 8 18:51:00.414] failed to validate user credentials (invalid format) ip=<HOST>:51782 subsystem=sftp username=logout"
#

[INCLUDES]

before = common.conf

[Definition]

_daemon = wings

failregex = failed to validate user credentials \([^\)]+\) ip=<HOST>:.* subsystem=sftp username=.*$

ignoreregex =

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, in order to increase the search performance from the systemd backend, it is great to add a journalmatch. Anyway, without it, I had a warning that told me this parameter was missing. Here is what I have done by my side: journalmatch = _SYSTEMD_UNIT=wings.service + _COMM=wings

[Init]

datepattern = \[%%b %%d %%H:%%M:%%S.%%f\]

### Step 5 enable the Fail2ban service to boot on startup and your done :D

`systemctl enable fail2ban`