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

Commit 4f67096

Browse files
authored
Merge pull request #97 from dev-sec/ssh_moduli
Remove small dh primes
2 parents 98034c0 + bff2813 commit 4f67096

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ env:
3939

4040
- distro: debian8
4141
version: latest
42+
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
4243
init: /sbin/init
4344

4445
- distro: debian9

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Warning: This role disables root-login on the target server! Please make sure yo
4444
|`sftp_enabled` | false | true to enable sftp configuration|
4545
|`sftp_chroot_dir` | /home/%u | change default sftp chroot location|
4646
|`ssh_client_roaming` | false | enable experimental client roaming|
47+
|`sshd_moduli_minimum` | 2048 | remove Diffie-Hellman parameters smaller than the defined size to mitigate logjam|
4748

4849
## Example Playbook
4950

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)