Alan Orth
0605f70f2e
This is active banning of IPs that are brute forcing login attempts to SSH, versus the passive banning of 10,000 abusive IPs from the abuseipdb.com blacklist. For now I am banning IPs that fail to log in successfully more than twelve times in a one-hour period, but these settings might change, and I can override them at the group and host level if needed. Currently this works for CentOS 7, Ubuntu 16.04, and Ubuntu 18.04, with minor differences in the systemd configuration due to older versions on some distributions. You can see the status of the jail like this: # fail2ban-client status sshd Status for the jail: sshd |- Filter | |- Currently failed: 0 | |- Total failed: 0 | `- Journal matches: _SYSTEMD_UNIT=sshd.service + _COMM=sshd `- Actions |- Currently banned: 1 |- Total banned: 1 `- Banned IP list: 106.13.112.20 You can unban IPs like this: # fail2ban-client set sshd unbanip 106.13.112.20 |
||
---|---|---|
group_vars | ||
host_vars | ||
misc-plays | ||
roles | ||
vars | ||
.gitignore | ||
ansible.cfg | ||
LICENSE | ||
Pipfile | ||
Pipfile.lock | ||
README.md | ||
site.yml | ||
web.yml |
Ansible Playbook
Ansible playbook for base and initial configuration of the web server hosting my personal websites. After successful execution of this playbook, however, there is still some manual work to import databases, copy site content, etc.
Assumptions
Before you can run this, a few things are assumed:
- You have a clean, minimal Debian 9, Ubuntu 16.04, Ubuntu 18.04, or Debian 10 host up and running
- Python 2 or 3 is installed on the remote server (requirement of Ansible)
- You have a user account with password-less SSH access to the machine
- You have sudo privileges on the remote host
- You have created a
hosts
file with something like:
[web]
web01
Use
Once you've satisfied the the above assumptions, you can execute:
$ ansible-playbook web.yml
Todo
- Switch from
cron-apt
tounattended-upgrades
License
Copyright (C) 2014 - 2019 Alan Orth
The contents of this repository are free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.