Nerd blog.

03 Aug 2014

Deploying Fail2Ban using SaltStack

One of the realities of having public facing SSH is the continual brute force attempts. I have 3 droplets at DigitalOcean, SGP1 and NYC2 get hit much more often than LON1. I thought about deploying SSH ACLs through SaltStack, but because all my systems are keys only, instead I deployed fail2ban with a custom configuration file to watch the bots get banned and laugh maniacally.

The relevant parts of config were as follows:


    - match: grain
    - settings.ntp.debian
    - settings.minion.debian
    - settings.fail2ban.debian


    - installed
    - running
    - require:
      - pkg: fail2ban
    - watch:
      - file: /etc/fail2ban/jail.local

    - managed
    - source: salt://settings/fail2ban/jail.local
    - require:
      - pkg: fail2ban

This deploys a custom jail.local file, which is the recommended way for deploying fail2ban.

This makes it quite easy to change ban times globally, or based on other grains.

Theodore Baschak - Theo is a network engineer with experience operating core internet technologies like HTTP, HTTPS and DNS. He has extensive experience running service provider networks with OSPF, MPLS, and BGP.