vm-ansible/roles/common/tasks/ssh-security-settings.yaml

25 lines
591 B
YAML
Raw Normal View History

---
- name: Disable root authentication
2023-03-05 19:00:38 +01:00
ansible.builtin.replace:
path: /etc/ssh/sshd_config
regexp: '#PermitRootLogin prohibit-password'
replace: 'PermitRootLogin no'
- name: Disable X11 forwarding
2023-03-05 19:00:38 +01:00
ansible.builtin.replace:
path: /etc/ssh/sshd_config
regexp: 'X11Forwarding yes'
replace: 'X11Forwarding no'
- name: Explicitly only listen on ipv4
2023-03-05 19:00:38 +01:00
ansible.builtin.replace:
path: /etc/ssh/sshd_config
regexp: '#AddressFamily any'
replace: 'AddressFamily inet'
2022-04-16 21:03:00 +02:00
- name: "Restart sshd"
2023-03-05 19:00:38 +01:00
ansible.builtin.service:
2022-04-16 21:03:00 +02:00
name: sshd
2022-04-16 21:05:42 +02:00
state: restarted
2022-04-16 19:55:29 +02:00
...