Skip to content

Commit da09dc9

Browse files
committed
fail2ban: add a ufw jail and filter (dmaroulidis)
Signed-off-by: nachoparker <nacho@ownyourbits.com>
1 parent 30c0f57 commit da09dc9

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

bin/ncp/SECURITY/fail2ban.sh

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Fail2ban installation script for Raspbian
3+
# Fail2ban for NextCloudPi
44
#
55
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
66
# GPL licensed (see end of file) * Use at your own risk!
@@ -46,11 +46,19 @@ echo "Starting fail2ban..."
4646
service fail2ban start
4747
4848
exit 0
49+
EOF
50+
51+
cat > /etc/fail2ban/filter.d/ufwban.conf <<'EOF'
52+
[INCLUDES]
53+
before = common.conf
54+
[Definition]
55+
failregex = UFW BLOCK.* SRC=
56+
ignoreregex =
4957
EOF
5058
chmod +x /etc/services-available.d/100fail2ban
5159
}
5260

53-
# tweak fail2ban email
61+
# tweak fail2ban email
5462
local F=/etc/fail2ban/action.d/sendmail-common.conf
5563
sed -i 's|Fail2Ban|NextCloudPi|' /etc/fail2ban/action.d/sendmail-whois-lines.conf
5664
grep -q actionstart_ "$F" || sed -i 's|actionstart|actionstart_|' "$F"
@@ -60,11 +68,11 @@ EOF
6068

6169
configure()
6270
{
63-
[[ $ACTIVE != "yes" ]] && {
71+
[[ $ACTIVE != "yes" ]] && {
6472
service fail2ban stop
6573
update-rc.d fail2ban disable
6674
echo "fail2ban disabled"
67-
return
75+
return
6876
}
6977

7078
local NCLOG="/var/www/nextcloud/data/nextcloud.log"
@@ -144,6 +152,13 @@ port = http,https
144152
filter = nextcloud
145153
logpath = $NCLOG
146154
maxretry = $MAXRETRY
155+
156+
[ufwban]
157+
enabled = true
158+
port = ssh, http, https
159+
filter = ufwban
160+
logpath = /var/log/ufw.log
161+
action = ufw
147162
EOF
148163
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
149164
update-rc.d fail2ban defaults

changelog.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11

2-
[v1.12.3](https://github.com/nextcloud/nextcloudpi/commit/b797129) (2019-05-11) nc-scan-auto: recursive and home-only options
2+
[v1.12.6](https://github.com/nextcloud/nextcloudpi/commit/e6ddc93) (2019-05-25) fail2ban: add a ufw jail and filter (dmaroulidis)
3+
4+
[v1.12.5 ](https://github.com/nextcloud/nextcloudpi/commit/30c0f57) (2019-05-25) ncp-web: update config reference URL
5+
6+
[v1.12.4 ](https://github.com/nextcloud/nextcloudpi/commit/c8d6222) (2019-05-26) ncp-web: Pt Translate (#907)
7+
8+
[v1.12.3 ](https://github.com/nextcloud/nextcloudpi/commit/d938481) (2019-05-11) nc-scan-auto: recursive and home-only options
39

410
[v1.12.2 ](https://github.com/nextcloud/nextcloudpi/commit/7589081) (2019-05-11) fix logrotate files
511

6-
[v1.12.1](https://github.com/nextcloud/nextcloudpi/commit/1be5ddd) (2019-05-01) Rename configuration variables into self-documenting ones (#889)
12+
[v1.12.1 ](https://github.com/nextcloud/nextcloudpi/commit/1be5ddd) (2019-05-01) Rename configuration variables into self-documenting ones (#889)
713

8-
[v1.12.0](https://github.com/nextcloud/nextcloudpi/commit/f34354c) (2019-04-29) ncp-web: add backups panel
14+
[v1.12.0 ](https://github.com/nextcloud/nextcloudpi/commit/f34354c) (2019-04-29) ncp-web: add backups panel
915

1016
[v1.11.5 ](https://github.com/nextcloud/nextcloudpi/commit/01cd421) (2019-04-29) letsencrypt: force renewal by default
1117

0 commit comments

Comments
 (0)