Da ich selber Owncloud einsetzt, möchte ich kurz zwei Möglichkeiten Beschreiben, wie man Owncloud bzw. auch NextCloud mit restriktiveren Rechten absichern kann.
	Rechte anpassen
Dazu habe ich hier einen interessanten Artikel gefunden. Das nachfolgende Skript ist daher bis auf die markierte Zeile identisch mit der verlinkten Quellen.
#!/bin/bash
ocpath='/../../owncloud/'
htuser='www-data'
htgroup='www-data'
rootuser='root'
printf "Creating possible missing Directories\n"
mkdir -p $ocpath/data
mkdir -p $ocpath/assets
mkdir -p $ocpath/updater
printf "chmod Files and Directories\n"
find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640
find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750
printf "chown Directories\n"
chown -R ${htuser}:${htgroup}  $ocpath
chown -R ${rootuser}:${htgroup} ${ocpath}/
chown -R ${htuser}:${htgroup} ${ocpath}/apps/
chown -R ${htuser}:${htgroup} ${ocpath}/assets/
chown -R ${htuser}:${htgroup} ${ocpath}/config/
chown -R ${htuser}:${htgroup} ${ocpath}/data/
chown -R ${htuser}:${htgroup} ${ocpath}/themes/
chown -R ${htuser}:${htgroup} ${ocpath}/updater/
chmod +x ${ocpath}/occ
printf "chmod/chown .htaccess\n"
if [ -f ${ocpath}/.htaccess ]
 then
  chmod 0644 ${ocpath}/.htaccess
  chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
fi
if [ -f ${ocpath}/data/.htaccess ]
 then
  chmod 0644 ${ocpath}/data/.htaccess
  chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess
fi
	fail2ban
Mein Owncloud schreibt die Log-Datei direkt in das syslog. Daher konnte ich die gefundenen Owncloud Regel nicht verwenden und musste diese kurzerhand anpassen.
/etc/fail2ban/filter.d/owncloud.conf
[Definition] failregex = .*ownCloud.*Login failed:.* \(Remote IP: \'<HOST>'\) ignoreregex =
/etc/fail2ban/jail.conf
[owncloud]enabled = true filter = owncloud port = http,https logpath = /var/log/syslog findtime = 600 bantime = 600 maxretry = 5
Abschließend fail2ban neustarte..
/etc/init.d/fail2ban restart
… kurz testen
fail2ban-regex /var/log/syslog /etc/fail2ban/filter.d/owncloud.conf
und wenn alles gut aussieht Haken dran.
fail2ban sperrt nun die IP Adressen für http & https Zugriffe nach fünf Fehlversuchen innerhalb von 10 Minuten für 10 Minuten.
Hinweis: Zu viele Firewall Regeln, je nach System bereits ab 150-200 können den Datendurchsatz schnell drastisch Beeinflussen.
