Configure fail2ban properly and test it before rollout to prod.
Issue
We need to add fail2ban config to the ssh proxy node to protect it against brute-force password and DDoS attacks when exposed to the internet. Remember users interface with the ssh-proxy for logging into Cheaha. So adding fail2ban config is important.
The ansible role for installing and configuring fail2ban was merged but never deployed in production because the testing was not comprehensive.
It was discovered that we need to add additional configuration to the fail2ban.
Proposed solution
The proposed solution comes in two layers.
- First, enable the failtoban plugin provided by sshpiper. SSHPiper offers a plugin at the application level -
failtoban
that acts as a drop-in for fail2ban. It would initially count failures and trigger the failtoban feature when a threshold (maxtries) is reached. The bantime and maxtries are configurable via the plugin.
This would prevent the user from logging in but doesn't prevent the application from being hit by requests. This is where the second layer comes to the rescue.
- Second, configure fail2ban to ban IP addresses conducting too many failed login attempts via jail.local configuration. Create fail2ban filter for sshpiperd which uses
failregex
to parse failed login attempt patterns in the log files. It adds firewalld rules in an ad-hoc manner via actions config in/etc/fail2ban/actions.d/
to reject new connections from those IP addresses, for the configured amount of time.