Compare commits

...

7 commits

Author SHA1 Message Date
Kevin Heyer
12635d0a43 init 2025-06-14 14:44:50 +02:00
Kevin Heyer
06ed516ff7 init 2025-06-14 14:44:45 +02:00
Kevin Heyer
b219111534 add fail2ban role 2025-06-14 14:44:38 +02:00
Kevin Heyer
8112a6cb30 remove rule of specific user 2025-06-14 14:44:25 +02:00
Kevin Heyer
09110e73df add fail2ban role 2025-06-14 14:43:53 +02:00
Kevin Heyer
04ce3e33a0 add default private key location 2025-06-14 14:43:28 +02:00
Kevin Heyer
f973808f0c update 2025-06-14 14:43:11 +02:00
19 changed files with 97 additions and 4 deletions

7
.gitignore vendored
View file

@ -4,10 +4,13 @@ inventory/
# Ignore .secret files.... you know, there secret...
*.secret
.vault-*
vault.secret
# Ignore Caching
cache/
# Ignore Testplaybook
playbooks/global/testserver.yml
playbooks/global/testserver.yml
# Ignore unneccessary Files
.vscode
.ansible

View file

@ -2,6 +2,7 @@
inventory = ./inventory/
host_key_checking = False
retry_files_enabled = False
private_key_file = ~/.ssh/ansible_key
# Caching-Einstellungen
gathering = smart
@ -26,4 +27,4 @@ become_ask_pass = False
[ssh_connection]
ssh_args = -o ControlMaster=auto -o ControlPersist=60s
pipelining = True
pipelining = True

View file

@ -0,0 +1,5 @@
---
- name: Install and start Apache web server
hosts: all
roles:
- server_install_ssh

View file

@ -0,0 +1,6 @@
---
- name: Install and start Apache web server
hosts: calibre
roles:
- server_install_ssh
- server_install_fail2ban

View file

@ -3,3 +3,4 @@
hosts: docker1
roles:
- server_install_ssh
- server_install_fail2ban

View file

@ -0,0 +1,6 @@
---
- name: Install and start Apache web server
hosts: minecraft
roles:
- server_install_ssh
- server_install_fail2ban

View file

@ -0,0 +1,6 @@
---
- name: Install and start Apache web server
hosts: pihole
roles:
- server_install_ssh
- server_install_fail2ban

View file

@ -0,0 +1,6 @@
---
- name: Install and start Apache web server
hosts: pve1
roles:
- server_install_ssh
- server_install_fail2ban

View file

@ -0,0 +1,6 @@
---
- name: Install and start Apache web server
hosts: pve2
roles:
- server_install_ssh
- server_install_fail2ban

View file

@ -0,0 +1,6 @@
---
- name: Install and start Apache web server
hosts: pve3
roles:
- server_install_ssh
- server_install_fail2ban

View file

@ -0,0 +1,5 @@
---
fail2ban_ssh_enabled: true
fail2ban_ssh_maxretry: 5
fail2ban_ssh_bantime: 1h
fail2ban_ssh_findtime: 1h

View file

@ -0,0 +1,5 @@
---
- name: Restart fail2ban
ansible.builtin.service:
name: fail2ban
state: restarted

View file

@ -0,0 +1,23 @@
---
- name: Update apt package index
ansible.builtin.apt:
update_cache: true
cache_valid_time: 3600
- name: Install Fail2Ban
ansible.builtin.apt:
name: fail2ban
state: present
- name: Ensure Fail2Ban service is enabled and running
ansible.builtin.service:
name: fail2ban
enabled: true
state: started
- name: Configure Fail2Ban for SSH
ansible.builtin.template:
src: jail.local.j2
dest: /etc/fail2ban/jail.local
mode: '0644'
notify: Restart fail2ban

View file

@ -0,0 +1,15 @@
[DEFAULT]
# Ignore local IP addresses
ignoreip = 127.0.0.1/8 ::1
# Ban settings
bantime = {{ fail2ban_ssh_bantime }}
findtime = {{ fail2ban_ssh_findtime }}
maxretry = {{ fail2ban_ssh_maxretry }}
[sshd]
enabled = {{ fail2ban_ssh_enabled | lower }}
port = ssh
filter = sshd
logpath = %(sshd_log)s
maxretry = {{ fail2ban_ssh_maxretry }}

View file

@ -6,7 +6,6 @@ PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM yes
X11Forwarding no
AllowUsers {{ ssh_user }}
ClientAliveInterval 300
ClientAliveCountMax 2
LoginGraceTime 30

View file

View file