Ansible/node-configuration/tasks/ssh.yml

32 lines
661 B
YAML
Raw Normal View History

2022-05-25 23:24:56 +00:00
---
2022-06-11 00:32:23 +00:00
- name: Ensures fail2ban dir exists
file:
path: /etc/fail2ban
state: directory
2022-05-25 23:24:56 +00:00
- name: Configure fail2ban
copy:
src: ../templates/fail2ban.conf
dest: /etc/fail2ban/fail2ban.conf
backup: yes
2022-06-11 00:32:23 +00:00
- name: Install fail2ban
ansible.builtin.package:
name: fail2ban
state: present
2022-05-25 23:24:56 +00:00
- name: Disable password login
lineinfile:
dest: "/etc/ssh/sshd_config"
regexp: '^(#\s*)?PasswordAuthentication '
line: "PasswordAuthentication no"
notify: restart sshd
- name: Change SSH port
lineinfile:
dest: "/etc/ssh/sshd_config"
regexp: "^Port "
line: "Port {{ sshd_port }}"
notify: restart sshd
when: 0 > 1