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

Commit 39e0aa4

Browse files
author
Sebastian Gumprich
committed
Merge pull request #60 from conorsch/move-vars-to-defaults
Moves vars to defaults
2 parents 9465db5 + eba9563 commit 39e0aa4

File tree

5 files changed

+93
-58
lines changed

5 files changed

+93
-58
lines changed

defaults/main.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,60 @@ sftp_chroot_dir: /home/%u
7777

7878
# enable experimental client roaming
7979
ssh_client_roaming: false
80+
81+
82+
ssh_ps53: 'yes'
83+
ssh_ps59: 'sandbox'
84+
85+
ssh_macs_53_default:
86+
- hmac-ripemd160
87+
- hmac-sha1
88+
89+
ssh_macs_59_default:
90+
- hmac-sha2-512
91+
- hmac-sha2-256
92+
- hmac-ripemd160
93+
94+
ssh_macs_59_weak: "{{ ssh_macs_59_default + ['hmac-sha1'] }}"
95+
96+
ssh_macs_66_default:
97+
- hmac-sha2-512-etm@openssh.com
98+
- hmac-sha2-256-etm@openssh.com
99+
- hmac-ripemd160-etm@openssh.com
100+
- umac-128-etm@openssh.com
101+
- hmac-sha2-512
102+
- hmac-sha2-256
103+
- hmac-ripemd160
104+
105+
ssh_macs_66_weak: "{{ ssh_macs_66_default + ['hmac-sha1'] }}"
106+
107+
ssh_ciphers_53_default:
108+
- aes256-ctr
109+
- aes192-ctr
110+
- aes128-ctr
111+
112+
ssh_ciphers_53_weak: "{{ ssh_ciphers_53_default + ['aes256-cbc', 'aes192-cbc', 'aes128-cbc'] }}"
113+
114+
ssh_ciphers_66_default:
115+
- chacha20-poly1305@openssh.com
116+
- aes256-gcm@openssh.com
117+
- aes128-gcm@openssh.com
118+
- aes256-ctr
119+
- aes192-ctr
120+
- aes128-ctr
121+
122+
ssh_ciphers_66_weak: "{{ ssh_ciphers_66_default + ['aes256-cbc', 'aes192-cbc', 'aes128-cbc'] }}"
123+
124+
ssh_kex_59_default:
125+
- diffie-hellman-group-exchange-sha256
126+
127+
ssh_kex_59_weak: "{{ ssh_kex_59_default + ['diffie-hellman-group14-sha1', 'diffie-hellman-group-exchange-sha1', 'diffie-hellman-group1-sha1'] }}"
128+
129+
ssh_kex_66_default:
130+
- curve25519-sha256@libssh.org
131+
- diffie-hellman-group-exchange-sha256
132+
133+
ssh_kex_66_weak: "{{ ssh_kex_66_default + ['diffie-hellman-group14-sha1', 'diffie-hellman-group-exchange-sha1', 'diffie-hellman-group1-sha1'] }}"
134+
135+
# directory where to store ssh_password policy
136+
ssh_custom_selinux_dir: '/etc/selinux/local-policies'

tasks/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,27 @@
2424
when: ssh_client_hardening
2525

2626
- name: Create selinux custom policy drop folder
27-
file: path={{ custom_selinux_dir }} state=directory owner=root group=root mode=0750
27+
file: path={{ ssh_custom_selinux_dir }} state=directory owner=root group=root mode=0750
2828
when: not ssh_use_pam and sestatus.rc == 0 and sestatus.stdout != 'Disabled'
2929

3030
# The following tasks only get executed when selinux is in state enforcing and UsePam is "no".
3131
# See this issue for more info: https://github.com/hardening-io/ansible-ssh-hardening/issues/23
3232

3333
- name: Distributing custom selinux policies
34-
copy: src='ssh_password' dest='{{ custom_selinux_dir }}'
34+
copy: src='ssh_password' dest='{{ ssh_custom_selinux_dir }}'
3535
register: custom_policies_output
3636
when: not ssh_use_pam and sestatus.rc == 0 and sestatus.stdout != 'Disabled'
3737

3838
- name: check and compile policy
39-
shell: checkmodule -M -m -o {{ custom_selinux_dir }}/ssh_password.mod {{ custom_selinux_dir }}/ssh_password
39+
shell: checkmodule -M -m -o {{ ssh_custom_selinux_dir }}/ssh_password.mod {{ ssh_custom_selinux_dir }}/ssh_password
4040
when: not ssh_use_pam and sestatus.rc == 0 and sestatus.stdout != 'Disabled'
4141

4242
- name: create selinux policy module package
43-
shell: semodule_package -o {{ custom_selinux_dir }}/ssh_password.pp -m {{ custom_selinux_dir }}/ssh_password.mod
43+
shell: semodule_package -o {{ ssh_custom_selinux_dir }}/ssh_password.pp -m {{ ssh_custom_selinux_dir }}/ssh_password.mod
4444
when: not ssh_use_pam and sestatus.rc == 0 and sestatus.stdout != 'Disabled'
4545

4646
- name: install selinux policy
47-
shell: semodule -i {{ custom_selinux_dir }}/ssh_password.pp
47+
shell: semodule -i {{ ssh_custom_selinux_dir }}/ssh_password.pp
4848
when: not ssh_use_pam and sestatus.rc == 0 and sestatus.stdout != 'Disabled'
4949

5050
- name: remove selinux-policy when Pam is used, because Allowing sshd to read the shadow file directly is considered a potential security risk (http://danwalsh.livejournal.com/12333.html)

templates/openssh.conf.j2

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ StrictHostKeyChecking ask
4848
#
4949
{% if ssh_client_cbc_required -%}
5050
{% if ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '14.04' -%}
51-
Ciphers {{ciphers_66_weak}}
51+
Ciphers {{ ssh_ciphers_66_weak | join(',') }}
5252
{% else -%}
53-
Ciphers {{ciphers_53_weak}}
53+
Ciphers {{ ssh_ciphers_53_weak | join(',') }}
5454
{% endif %}
5555
{% else -%}
5656
{% if ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '14.04' -%}
57-
Ciphers {{ciphers_66_default}}
57+
Ciphers {{ ssh_ciphers_66_default | join(',') }}
5858
{% else -%}
59-
Ciphers {{ciphers_53_default}}
59+
Ciphers {{ ssh_ciphers_53_default | join(',') }}
6060
{% endif %}
6161
{% endif %}
6262

@@ -66,23 +66,23 @@ StrictHostKeyChecking ask
6666
#
6767
{% if ssh_client_weak_hmac -%}
6868
{% if ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '14.04' -%}
69-
MACs {{macs_66_weak}}
69+
MACs {{ ssh_macs_66_weak | join(',') }}
7070
{% elif ansible_os_family in ['Oracle Linux', 'RedHat'] and ansible_distribution_major_version <= '6' -%}
71-
MACs {{macs_53_default}}
71+
MACs {{ ssh_macs_53_default | join(',') }}
7272
{% elif ansible_distribution == 'Debian' and ansible_distribution_major_version <= '6' -%}
73-
MACs {{macs_53_default}}
73+
MACs {{ ssh_macs_53_default | join(',') }}
7474
{% else -%}
75-
MACs {{macs_59_weak}}
75+
MACs {{ ssh_macs_59_weak | join(',') }}
7676
{% endif %}
7777
{% else -%}
7878
{% if ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '14.04' -%}
79-
MACs {{macs_66_default}}
79+
MACs {{ ssh_macs_66_default | join(',') }}
8080
{% elif ansible_os_family in ['Oracle Linux', 'RedHat'] and ansible_distribution_major_version <= '6' -%}
81-
MACs {{macs_53_default}}
81+
MACs {{ ssh_macs_53_default | join(',') }}
8282
{% elif ansible_distribution == 'Debian' and ansible_distribution_major_version <= '6' -%}
83-
MACs {{macs_53_default}}
83+
MACs {{ ssh_macs_53_default | join(',') }}
8484
{% else -%}
85-
MACs {{macs_59_default}}
85+
MACs {{ ssh_macs_59_default | join(',') }}
8686
{% endif %}
8787
{% endif %}
8888

@@ -95,17 +95,17 @@ StrictHostKeyChecking ask
9595
#
9696
{% if ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '14.04' -%}
9797
{% if ssh_client_weak_kex -%}
98-
KexAlgorithms {{kex_66_weak}}
98+
KexAlgorithms {{ ssh_kex_66_weak | join(',') }}
9999
{% else -%}
100-
KexAlgorithms {{kex_66_default}}
100+
KexAlgorithms {{ ssh_kex_66_default | join(',') }}
101101
{% endif %}
102102
{% else -%}
103103
{% if ansible_os_family in ['Oracle Linux', 'RedHat'] or (ansible_distribution == 'Debian' and ansible_distribution_major_version <= '6') -%}
104104
#KexAlgorithms
105105
{% elif ssh_client_weak_kex -%}
106-
KexAlgorithms {{kex_59_weak}}
106+
KexAlgorithms {{ ssh_kex_59_weak | join(',') }}
107107
{% else -%}
108-
KexAlgorithms {{kex_59_default}}
108+
KexAlgorithms {{ ssh_kex_59_default | join(',') }}
109109
{% endif %}
110110
{% endif %}
111111

templates/opensshd.conf.j2

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ LogLevel VERBOSE
5252
#
5353
{% if ssh_server_cbc_required -%}
5454
{% if ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '14.04' -%}
55-
Ciphers {{ciphers_66_weak}}
55+
Ciphers {{ ssh_ciphers_66_weak | join(',') }}
5656
{% else %}
57-
Ciphers {{ciphers_53_weak}}
57+
Ciphers {{ ssh_ciphers_53_weak | join(',') }}
5858
{% endif %}
5959
{% else -%}
6060
{% if ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '14.04' -%}
61-
Ciphers {{ciphers_66_default}}
61+
Ciphers {{ ssh_ciphers_66_default | join(',') }}
6262
{% else -%}
63-
Ciphers {{ciphers_53_default}}
63+
Ciphers {{ ssh_ciphers_53_default | join(',') }}
6464
{% endif %}
6565
{% endif %}
6666

@@ -71,23 +71,23 @@ LogLevel VERBOSE
7171

7272
{% if ssh_server_weak_hmac -%}
7373
{% if ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '14.04' -%}
74-
MACs {{macs_66_weak}}
74+
MACs {{ ssh_macs_66_weak | join(',') }}
7575
{% elif ansible_os_family in ['Oracle Linux', 'RedHat'] and ansible_distribution_major_version <= '6' -%}
76-
MACs {{macs_53_default}}
76+
MACs {{ ssh_macs_53_default | join(',') }}
7777
{% elif ansible_distribution == 'Debian' and ansible_distribution_major_version <= '6' -%}
78-
MACs {{macs_53_default}}
78+
MACs {{ ssh_macs_53_default | join(',') }}
7979
{% else -%}
80-
MACs {{macs_59_weak}}
80+
MACs {{ ssh_macs_59_weak | join(',') }}
8181
{% endif %}
8282
{% else -%}
8383
{% if ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '14.04' -%}
84-
MACs {{macs_66_default}}
84+
MACs {{ ssh_macs_66_default | join(',') }}
8585
{% elif ansible_os_family in ['Oracle Linux', 'RedHat'] and ansible_distribution_major_version <= '6' -%}
86-
MACs {{macs_53_default}}
86+
MACs {{ ssh_macs_53_default | join(',') }}
8787
{% elif ansible_distribution == 'Debian' and ansible_distribution_major_version <= '6' -%}
88-
MACs {{macs_53_default}}
88+
MACs {{ ssh_macs_53_default | join(',') }}
8989
{% else -%}
90-
MACs {{macs_59_default}}
90+
MACs {{ ssh_macs_59_default | join(',') }}
9191
{% endif %}
9292
{% endif %}
9393

@@ -100,15 +100,15 @@ LogLevel VERBOSE
100100
# based on: https://bettercrypto.org/static/applied-crypto-hardening.pdf
101101
{% if ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '14.04' -%}
102102
{% if ssh_client_weak_kex -%}
103-
KexAlgorithms {{kex_66_weak}}
103+
KexAlgorithms {{ ssh_kex_66_weak | join(',') }}
104104
{% else -%}
105-
KexAlgorithms {{kex_66_default}}
105+
KexAlgorithms {{ ssh_kex_66_default | join(',') }}
106106
{% endif %}
107107
{% else -%}
108108
{% if ansible_os_family in ['Oracle Linux', 'RedHat'] or (ansible_distribution == 'Debian' and ansible_distribution_major_version <= '6') -%}
109109
#KexAlgorithms
110110
{% else -%}
111-
KexAlgorithms {{kex_59_default}}
111+
KexAlgorithms {{ ssh_kex_59_default | join(',') }}
112112
{% endif %}
113113
{% endif %}
114114

vars/main.yml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +0,0 @@
1-
ssh_ps53: 'yes'
2-
ssh_ps59: 'sandbox'
3-
4-
macs_53_default: 'hmac-ripemd160,hmac-sha1'
5-
macs_59_default: 'hmac-sha2-512,hmac-sha2-256,hmac-ripemd160'
6-
macs_59_weak: '{{macs_59_default + ",hmac-sha1"}}'
7-
macs_66_default: 'hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-ripemd160-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-ripemd160'
8-
macs_66_weak: '{{macs_66_default + ",hmac-sha1"}}'
9-
10-
ciphers_53_default: 'aes256-ctr,aes192-ctr,aes128-ctr'
11-
ciphers_53_weak: '{{ciphers_53_default + ",aes256-cbc,aes192-cbc,aes128-cbc"}}'
12-
13-
ciphers_66_default: 'chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr'
14-
ciphers_66_weak: '{{ciphers_66_default + ",aes256-cbc,aes192-cbc,aes128-cbc"}}'
15-
16-
kex_59_default: 'diffie-hellman-group-exchange-sha256'
17-
kex_59_weak: '{{kex_59_default + ",diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1"}}'
18-
kex_66_default: 'curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256'
19-
kex_66_weak: '{{kex_66_default + ",diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1"}}'
20-
21-
# directory where to store ssh_password policy
22-
custom_selinux_dir: '/etc/selinux/local-policies'

0 commit comments

Comments
 (0)