initial transfer
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
# armor-fail2ban
|
||||
|
||||
**Install and enable fail2ban**
|
||||
|
||||
## Purpose
|
||||
|
||||
This cube installs and configures Fail2ban, an intrusion prevention software that protects your server from brute-force attacks and unauthorized access attempts.
|
||||
|
||||
## What is Fail2ban?
|
||||
|
||||
Fail2ban monitors log files (e.g., `/var/log/auth.log`) for suspicious activity, such as repeated failed login attempts. When it detects malicious behavior patterns, it automatically:
|
||||
|
||||
- Bans the offending IP address by updating firewall rules
|
||||
- Prevents the attacker from making further connection attempts
|
||||
- Can send email notifications about bans (if configured)
|
||||
|
||||
Common use cases include:
|
||||
- Protecting SSH from brute-force password attacks
|
||||
- Blocking repeated failed login attempts on web applications
|
||||
- Preventing DoS attacks from specific IP addresses
|
||||
|
||||
## What This Cube Does
|
||||
|
||||
1. Installs the `fail2ban` package via apt
|
||||
2. Deploys a custom configuration file (`jail.local`) to `/etc/fail2ban/jail.local`
|
||||
3. Configures fail2ban with sensible defaults for common services
|
||||
|
||||
## Configuration
|
||||
|
||||
This cube currently has no configurable parameters. The default configuration is applied from the included `jail.local` file.
|
||||
|
||||
## Dependencies
|
||||
|
||||
None - this cube can run standalone.
|
||||
|
||||
## Notes
|
||||
|
||||
After deployment, you can:
|
||||
- Check fail2ban status: `sudo fail2ban-client status`
|
||||
- View banned IPs: `sudo fail2ban-client status sshd`
|
||||
- Unban an IP: `sudo fail2ban-client set sshd unbanip <IP_ADDRESS>`
|
||||
@@ -0,0 +1,18 @@
|
||||
from pyinfra.operations import apt, files, server
|
||||
|
||||
# Install Fail2ban
|
||||
apt.packages(
|
||||
name='Install Fail2ban',
|
||||
packages=['fail2ban'],
|
||||
update=True,
|
||||
_sudo=True
|
||||
)
|
||||
|
||||
# Configure Fail2ban
|
||||
files.put(
|
||||
name='Configure Fail2ban',
|
||||
src='jail.local',
|
||||
dest='/etc/fail2ban/jail.local',
|
||||
mode='0644',
|
||||
_sudo=True
|
||||
)
|
||||
@@ -0,0 +1,8 @@
|
||||
[sshd]
|
||||
enabled = true
|
||||
port = ssh
|
||||
filter = sshd
|
||||
logpath = /var/log/auth.log
|
||||
maxretry = 3
|
||||
findtime = 600
|
||||
bantime = 3600
|
||||
@@ -0,0 +1,7 @@
|
||||
import { cubes } from '@bitstack/nopy';
|
||||
|
||||
export default cubes.Manifest({
|
||||
id: 'armor:fail2ban',
|
||||
name: 'Install and enable fail2ban',
|
||||
dependencies: () => [],
|
||||
});
|
||||
Reference in New Issue
Block a user