ansible-personal/roles/common/tasks
Alan Orth 0605f70f2e
roles/common: Add support for fail2ban
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
2019-10-26 16:36:07 +02:00
..
cron-apt.yml Update with_items loops to use new-ish "loop" keyword 2018-04-02 15:52:51 +03:00
fail2ban.yml roles/common: Add support for fail2ban 2019-10-26 16:36:07 +02:00
firewall_Debian.yml roles/common: Add support for fail2ban 2019-10-26 16:36:07 +02:00
firewall_Ubuntu.yml roles/common: Add support for fail2ban 2019-10-26 16:36:07 +02:00
main.yml roles/common: Use a persistent systemd journal 2018-12-07 23:46:18 +02:00
ntp.yml roles/common: Update comment in tasks/ntp.yml 2019-07-06 21:16:19 +03:00
packages_Debian.yml roles/common: Remove lzop and lrzip from packages 2019-09-15 13:23:52 +03:00
packages_Ubuntu.yml roles/common: Remove lzop and lrzip from packages 2019-09-15 13:23:52 +03:00
ssh-keys.yml roles/common: Add functionality to copy user keys to provisioning user 2014-10-11 12:13:45 +03:00
sshd.yml Update with_items loops to use new-ish "loop" keyword 2018-04-02 15:52:51 +03:00
tarsnap.yml roles/common: Use experimental Tarsnap on Debian buster 2019-07-19 12:07:27 +03:00