1
0
Fork 0

Initial commit

This commit is contained in:
Andrew Tomaka 2022-12-21 22:56:39 -05:00
commit d6bd3862eb
Signed by: atomaka
GPG key ID: 61209BF70A5B18BE
19 changed files with 357 additions and 0 deletions

View file

@ -0,0 +1,9 @@
- name: Restart ssh
service:
name: sshd
state: restarted
- name: Restart fail2ban
service:
name: fail2ban
state: restarted

36
roles/ssh/tasks/main.yml Normal file
View file

@ -0,0 +1,36 @@
---
- name: Block root and password authentication
lineinfile:
path: /etc/ssh/sshd_config
regexp: '{{ item.regexp }}'
line: '{{ item.line }}'
validate: 'sshd -T -f %s'
state: present
with_items:
- regexp: '^PasswordAuthentication'
line: 'PasswordAuthentication no'
- regexp: '^PermitRootLogin'
line: 'PermitRootLogin no'
notify: Restart ssh
- name: Install fail2ban
apt:
name: fail2ban
state: present
- name: Configure fail2ban
blockinfile:
path: /etc/fail2ban/jail.local
create: yes
mode: 0644
block: |
[sshd]
enabled = true
filter = sshd
notify: Restart fail2ban
- name: Start fail2ban on boot
service:
name: fail2ban
enabled: true
state: started