xoxys.sshd/tasks/ssh_default.yml

45 lines
1.2 KiB
YAML
Raw Normal View History

2019-11-02 18:10:39 +00:00
---
- name: Gather package facts
package_facts:
check_mode: False
2019-11-02 18:10:39 +00:00
- block:
- name: Hardening sshd config
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
shell: awk '$5 < {{ sshd_moduli_minimum }}' /etc/ssh/moduli
register: __sshd_register_moduli
changed_when: False
check_mode: no
- name: Remove all small primes
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
2019-11-02 18:10:39 +00:00
notify: __sshd_restart
when: __sshd_register_moduli.stdout
2022-09-18 20:21:56 +00:00
- name: Create SSH usergroup
2019-11-02 18:10:39 +00:00
group:
name: "{{ item }}"
state: present
loop: "{{ sshd_allow_groups }}"
2022-09-18 20:28:55 +00:00
- name: Configure SSH crypto policy usage
template:
src: etc/sysconfig/sshd.j2
dest: /etc/sysconfig/sshd
owner: root
group: root
mode: 0640
2022-09-18 20:23:48 +00:00
when: ('crypto-policies' in ansible_facts.packages)
2019-11-02 18:10:39 +00:00
become: True
become_user: root