├── .gitignore ├── README.md └── automated-install ├── fail2ban ├── filter.owncloud.conf └── jail.owncloud.conf └── install.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # owncloud-fail2ban 2 | 3 | This is an automated installer and updater for fail2ban, which installs and updates fail2ban filters and sets the specific owncloud configurations. 4 | 5 | ## Install 6 | Just execute the following command and the fail2ban filter for owncloud will be activated and set up: 7 | 8 | ```curl -s "https://raw.githubusercontent.com/AykutCevik/owncloud-fail2ban/master/automated-install/install.sh" | bash``` 9 | 10 | ## Current version (10.*) 11 | The script has been tested with owncloud 10.0.8 and Ubuntu, but may also run under other versions and distributions. If not, please let me know. 12 | 13 | ## Owncloud 9.* 14 | Find the installer in the following branch: https://github.com/AykutCevik/owncloud-fail2ban/tree/owncloud-9.0 15 | 16 | ## Owncloud 8.2.* 17 | Find the installer in the following branch: https://github.com/AykutCevik/owncloud-fail2ban/tree/owncloud-8.2 18 | 19 | ## Owncloud 8.1.* 20 | Find the installer in the following branch: https://github.com/AykutCevik/owncloud-fail2ban/tree/owncloud-8.1 21 | 22 | ## Owncloud 8.0.* 23 | Find the installer in the following branch: https://github.com/AykutCevik/owncloud-fail2ban/tree/owncloud-8.0 -------------------------------------------------------------------------------- /automated-install/fail2ban/filter.owncloud.conf: -------------------------------------------------------------------------------- 1 | [INCLUDES] 2 | before = common.conf 3 | 4 | [Definition] 5 | _daemon = owncloud 6 | 7 | failregex={"reqId":".*","level":2,"time":".*","remoteAddr":".*","user":".*","app":"core","method":"POST","url":".*","message":"Login failed: '.*' \(Remote IP: ''\)"} 8 | ignoreregex = -------------------------------------------------------------------------------- /automated-install/fail2ban/jail.owncloud.conf: -------------------------------------------------------------------------------- 1 | [owncloud] 2 | enabled = true 3 | filter = owncloud 4 | port = http,https 5 | -------------------------------------------------------------------------------- /automated-install/install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Automated installer for owncloud fail2ban configuration. 3 | # 4 | # Install with this command on your server: 5 | # curl -s "https://raw.githubusercontent.com/AykutCevik/owncloud-fail2ban/master/automated-install/install.sh" | bash 6 | # Or run the commands below in given order. 7 | # 8 | # Script may also run under other versions of owncloud. 9 | 10 | clear 11 | echo " _____ ___ __ ___| | ___ _ _ __| | / _| __ _(_) |___ \| |__ __ _ _ __ " 12 | echo " / _ \ \ /\ / / '_ \ / __| |/ _ \| | | |/ _' |_____| |_ / _' | | | __) | '_ \ / _' | '_ \ " 13 | echo "| (_) \ V V /| | | | (__| | (_) | |_| | (_| |_____| _| (_| | | |/ __/| |_) | (_| | | | |" 14 | echo " \___/ \_/\_/ |_| |_|\___|_|\___/ \__,_|\__,_| |_| \__,_|_|_|_____|_.__/ \__,_|_| |_|" 15 | echo " __Owncloud 10.* fail2ban installer__" 16 | echo "" 17 | 18 | JAILFILE="/etc/fail2ban/jail.d/owncloud.conf" 19 | FILTERFILE="/etc/fail2ban/filter.d/owncloud.conf" 20 | OWNCLOUDLOG="" 21 | if [[ -f $JAILFILE ]];then 22 | echo "Already installed, updating owncloud filter." 23 | OWNCLOUDLOG=$(awk -F "=" '/logpath/ {print $2}' $JAILFILE) 24 | else 25 | echo "Installing. Please provide your owncloud log path once. Updates will fetch it automatically." 26 | echo "Owncloud logpath: " 27 | read OWNCLOUDLOG /dev/null 31 | sudo apt-get -y install fail2ban 32 | fi 33 | 34 | echo "Downloading configurations..." 35 | sudo curl -o "$FILTERFILE" "https://raw.githubusercontent.com/AykutCevik/owncloud-fail2ban/master/automated-install/fail2ban/filter.owncloud.conf" 36 | sudo curl -o "$JAILFILE" "https://raw.githubusercontent.com/AykutCevik/owncloud-fail2ban/master/automated-install/fail2ban/jail.owncloud.conf" 37 | 38 | echo "Setting log path..." 39 | echo "logpath = $OWNCLOUDLOG" | sudo tee -a "$JAILFILE" 40 | 41 | echo "Activating new owncloud filter. Restarting fail2ban..." 42 | sudo /etc/init.d/fail2ban restart 43 | 44 | echo "Work is done!" 45 | --------------------------------------------------------------------------------