Skip to content
This repository was archived by the owner on Dec 26, 2020. It is now read-only.

Commit aac6f60

Browse files
Sebastian GumprichSebastian Gumprich
authored andcommitted
Remove small dh primes
Thanks to debops! https://github.com/debops/ansible-sshd/
1 parent 98034c0 commit aac6f60

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,5 @@ ssh_kex_66_weak: "{{ ssh_kex_66_default + ['diffie-hellman-group14-sha1', 'diffi
140140

141141
# directory where to store ssh_password policy
142142
ssh_custom_selinux_dir: '/etc/selinux/local-policies'
143+
144+
sshd_moduli_minimum: 2048

tasks/main.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@
1515
template: src='openssh.conf.j2' dest='/etc/ssh/ssh_config' mode=0644 owner=root group=root
1616
when: ssh_client_hardening
1717

18+
- name: Check if /etc/ssh/moduli contains weak DH parameters
19+
shell: awk '$5 < {{ sshd_moduli_minimum }}' /etc/ssh/moduli
20+
register: sshd_register_moduli
21+
changed_when: false
22+
always_run: True
23+
24+
- name: remove all small primes
25+
shell: awk '$5 >= {{ sshd_moduli_minimum }}' /etc/ssh/moduli > /etc/ssh/moduli.new ;
26+
[ -r /etc/ssh/moduli.new -a -s /etc/ssh/moduli.new ] && mv /etc/ssh/moduli.new /etc/ssh/moduli || true
27+
notify: restart sshd
28+
when: sshd_register_moduli.stdout
29+
1830
- name: test to see if selinux is running
1931
command: getenforce
2032
register: sestatus

0 commit comments

Comments
 (0)