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

Commit 147a26c

Browse files
authored
Merge pull request #305 from dev-sec/order_crypto
add blocks to crypto.yml checks
2 parents d87f6c6 + fda42b7 commit 147a26c

File tree

6 files changed

+82
-76
lines changed

6 files changed

+82
-76
lines changed

tasks/crypto.yml

-74
This file was deleted.

tasks/crypto_ciphers.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
- name: set ciphers according to openssh-version if openssh >= 5.3
3+
set_fact:
4+
ssh_ciphers: '{{ ssh_ciphers_53_default }}'
5+
when: sshd_version is version('5.3', '>=')
6+
7+
- name: set ciphers according to openssh-version if openssh >= 6.6
8+
set_fact:
9+
ssh_ciphers: '{{ ssh_ciphers_66_default }}'
10+
when: sshd_version is version('6.6', '>=')

tasks/crypto_hostkeys.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
- name: set hostkeys according to openssh-version if openssh >= 5.3
3+
set_fact:
4+
ssh_host_key_files: ['/etc/ssh/ssh_host_rsa_key']
5+
when: sshd_version is version('5.3', '>=')
6+
7+
- name: set hostkeys according to openssh-version if openssh >= 6.0
8+
set_fact:
9+
ssh_host_key_files: ['/etc/ssh/ssh_host_rsa_key', '/etc/ssh/ssh_host_ecdsa_key']
10+
when: sshd_version is version('6.0', '>=')
11+
12+
- name: set hostkeys according to openssh-version if openssh >= 6.3
13+
set_fact:
14+
ssh_host_key_files: ['/etc/ssh/ssh_host_rsa_key', '/etc/ssh/ssh_host_ecdsa_key', '/etc/ssh/ssh_host_ed25519_key']
15+
when: sshd_version is version('6.3', '>=')

tasks/crypto_kex.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
- name: set kex according to openssh-version if openssh >= 5.9
3+
set_fact:
4+
ssh_kex: '{{ ssh_kex_59_default }}'
5+
when: sshd_version is version('5.9', '>=')
6+
7+
- name: set kex according to openssh-version if openssh >= 6.6
8+
set_fact:
9+
ssh_kex: '{{ ssh_kex_66_default }}'
10+
when: sshd_version is version('6.6', '>=')
11+
12+
- name: set kex according to openssh-version if openssh >= 8.0
13+
set_fact:
14+
ssh_kex: '{{ ssh_kex_80_default }}'
15+
when: sshd_version is version('8.0', '>=')

tasks/crypto_macs.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
- name: set macs according to openssh-version if openssh >= 5.3
3+
set_fact:
4+
ssh_macs: '{{ ssh_macs_53_default }}'
5+
when: sshd_version is version('5.3', '>=')
6+
7+
- name: set macs for Enterprise Linux >= 6.5 (openssh 5.3 with backports)
8+
set_fact:
9+
ssh_macs: '{{ ssh_macs_53_el_6_5_default }}'
10+
when:
11+
- ansible_facts.distribution in ['CentOS', 'OracleLinux', 'RedHat']
12+
- ansible_facts.distribution_version is version('6.5', '>=')
13+
14+
- name: set macs according to openssh-version if openssh >= 5.9
15+
set_fact:
16+
ssh_macs: '{{ ssh_macs_59_default }}'
17+
when: sshd_version is version('5.9', '>=')
18+
19+
- name: set macs according to openssh-version if openssh >= 6.6
20+
set_fact:
21+
ssh_macs: '{{ ssh_macs_66_default }}'
22+
when: sshd_version is version('6.6', '>=')
23+
24+
- name: set macs according to openssh-version if openssh >= 7.6
25+
set_fact:
26+
ssh_macs: '{{ ssh_macs_76_default }}'
27+
when: sshd_version is version('7.6', '>=')

tasks/hardening.yml

+15-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,21 @@
1717
set_fact:
1818
sshd_version: "{{ sshd_version_raw.stderr | regex_replace('.*_([0-9]*.[0-9]).*', '\\1') }}"
1919

20-
- name: include tasks to create crypto-vars
21-
include_tasks: crypto.yml
20+
- name: set default for ssh_host_key_files if not supplied
21+
include_tasks: crypto_hostkeys.yml
22+
when: not ssh_host_key_files
23+
24+
- name: set default for ssh_macs if not supplied
25+
include_tasks: crypto_macs.yml
26+
when: not ssh_macs
27+
28+
- name: set default for ssh_ciphers if not supplied
29+
include_tasks: crypto_ciphers.yml
30+
when: not ssh_ciphers
31+
32+
- name: set default for ssh_kex if not supplied
33+
include_tasks: crypto_kex.yml
34+
when: not ssh_kex
2235

2336
- name: create revoked_keys and set permissions to root/600
2437
template:

0 commit comments

Comments
 (0)