xoxys.sshd/tasks/ssh_default.yml
Robert Kaussow 3afa931e05
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/notify Pipeline was successful
ci/woodpecker/push/docs Pipeline was successful
ci: migrate to woodpecker
2024-02-18 13:22:43 +01:00

42 lines
1.1 KiB
YAML

---
- name: Gather package facts
ansible.builtin.package_facts:
check_mode: False
- name: Hardening sshd config
ansible.builtin.template:
src: etc/ssh/sshd_config.j2
dest: /etc/ssh/sshd_config
owner: root
group: root
mode: "0600"
notify: __sshd_restart
- name: Check if /etc/ssh/moduli contains weak DH parameters
ansible.builtin.shell: awk '$5 < {{ sshd_moduli_minimum }}' /etc/ssh/moduli
register: __sshd_register_moduli
changed_when: False
check_mode: False
- name: Remove all small primes
ansible.builtin.shell:
awk '$5 >= {{ sshd_moduli_minimum }}' /etc/ssh/moduli > /etc/ssh/moduli.new ;
[ -r /etc/ssh/moduli.new -a -s /etc/ssh/moduli.new ] && mv /etc/ssh/moduli.new /etc/ssh/moduli || true
notify: __sshd_restart
when: __sshd_register_moduli.stdout
- name: Create SSH usergroup
ansible.builtin.group:
name: "{{ item }}"
state: present
loop: "{{ sshd_allow_groups }}"
- name: Configure SSH crypto policy usage
ansible.builtin.template:
src: etc/sysconfig/sshd.j2
dest: /etc/sysconfig/sshd
owner: root
group: root
mode: "0640"
when: ('crypto-policies' in ansible_facts.packages)