Skip to content

Commit

Permalink
Set ban correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
jaydrogers committed Aug 29, 2024
1 parent 88af01e commit 46ceecd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ COPY proftpd.conf /etc/proftpd/proftpd.conf
RUN useradd -r -s /bin/false ${FTP_USER}

# Create a directory for FTP and set permissions
RUN mkdir -p /var/ftp && \
RUN mkdir -p /var/ftp/ && \
touch /var/ftp/ban.tab && \
chown -R ${FTP_USER}:${FTP_GROUP} /var/ftp

# Generate self-signed SSL certificate
Expand Down
16 changes: 12 additions & 4 deletions src/proftpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ DefaultServer on
LoadModule mod_tls.c
LoadModule mod_sql.c
LoadModule mod_sql_mysql.c
LoadModule mod_ban.c

# Port 21 is the standard FTP port.
Port 21
Expand Down Expand Up @@ -83,13 +84,20 @@ AuthPAM off
</Limit>

<IfModule mod_ban.c>
# Set maximum login attempts per connection
MaxLoginAttempts 1

BanEngine on
BanLog /var/log/proftpd/ban.log
BanTable /var/ftp/ban.tab

# Ban IP addresses that reach MaxLoginAttempts 5 times in 10 minutes, for 1 hour
BanOnEvent MaxLoginAttempts 5/00:10:00 01:00:00

# Ban IP addresses that fail authentication 5 times in 10 minutes
BanOnEvent BadPassword 5/00:10:00 00:60:00
# Instantly ban anonymous login attempts
BanOnEvent AnonRejectPasswords 1/00:00:01 99:99:99

# Control connection policy
BanControlsACLs all allow user root
BanControlsACLs all deny all
BanControlsACLs all allow user proftpd_user
BanMessage "Host %a has been banned"
</IfModule>

0 comments on commit 46ceecd

Please sign in to comment.