hac/ansible/roles/sshd/tasks/main.yml
2024-04-17 11:23:04 +02:00

40 lines
885 B
YAML

---
- name: Disable Password Authentication
ansible.builtin.lineinfile:
dest: /etc/ssh/sshd_config
regexp: ^PasswordAuthentication
line: PasswordAuthentication no
state: present
backup: true
notify:
- Restart SSH
- name: Disable Root Login
ansible.builtin.lineinfile:
dest: /etc/ssh/sshd_config
regexp: ^PermitRootLogin
line: PermitRootLogin no
state: present
backup: true
notify:
- Restart SSH
- name: Restrict host key
ansible.builtin.lineinfile:
dest: /etc/ssh/sshd_config
regexp: "#HostKey /etc/ssh/ssh_host_ed25519_key"
line: HostKey /etc/ssh/ssh_host_ed25519_key
state: present
backup: true
notify:
- Restart SSH
- name: Configure sshd
ansible.builtin.copy:
src: crypto.conf
dest: /etc/ssh/sshd_config.d/
owner: root
group: root
mode: "0640"
notify:
- Restart SSH