@@ -48,40 +48,15 @@ LogLevel VERBOSE
4848# eg ruby Net::SSH::Transport::CipherFactory requires cbc-versions of the given openssh ciphers to work
4949# -- see: (http://net-ssh.github.com/net-ssh/classes/Net/SSH/Transport/CipherFactory.html)
5050#
51- {% if ssh_server_cbc_required -%}
52- {% if (ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '14.04' ) or (ansible_distribution == 'Debian' and ansible_distribution_version >= '8' ) or (ansible_os_family in ['Oracle Linux' , 'RedHat' ] and ansible_distribution_major_version >= '7' ) or (ansible_distribution == 'FreeBSD' and ansible_distribution_version >= '11' ) -%}
53- Ciphers {{ ssh_ciphers_66_weak | join(',') }}
54- {% else %}
55- Ciphers {{ ssh_ciphers_53_weak | join(',') }}
56- {% endif %}
57- {% else -%}
58- {% if (ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '14.04' ) or (ansible_distribution == 'Debian' and ansible_distribution_version >= '8' ) or (ansible_os_family in ['Oracle Linux' , 'RedHat' ] and ansible_distribution_major_version >= '7' ) or (ansible_distribution == 'FreeBSD' and ansible_distribution_version >= '11' ) -%}
59- Ciphers {{ ssh_ciphers_66_default | join(',') }}
60- {% else -%}
61- Ciphers {{ ssh_ciphers_53_default | join(',') }}
62- {% endif %}
63- {% endif %}
51+
52+ {{ "Ciphers "+ssh_ciphers| join(',') if ssh_ciphers else "Ciphers"|comment }}
6453
6554# **Hash algorithms** -- Make sure not to use SHA1 for hashing, unless it is really necessary.
6655# Weak HMAC is sometimes required if older package versions are used
6756# eg Ruby's Net::SSH at around 2.2.* doesn't support sha2 for hmac, so this will have to be set true in this case.
6857#
6958
70- {% if ssh_server_weak_hmac -%}
71- {% if (ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '14.04' ) or (ansible_distribution == 'Debian' and ansible_distribution_version >= '8' ) or (ansible_os_family in ['Oracle Linux' , 'RedHat' ] and ansible_distribution_major_version >= '7' ) or (ansible_distribution == 'FreeBSD' and ansible_distribution_version >= '11' ) -%}
72- MACs {{ ssh_macs_66_weak | join(',') }}
73- {% elif ansible_os_family in ['Oracle Linux' , 'RedHat' ] and ansible_distribution_major_version <= '6' -%}
74- MACs {{ ssh_macs_53_default | join(',') }}
75- {% endif %}
76- {% else -%}
77- {% if (ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '14.04' ) or (ansible_distribution == 'Debian' and ansible_distribution_version >= '8' ) or (ansible_os_family in ['Oracle Linux' , 'RedHat' ] and ansible_distribution_major_version >= '7' ) or (ansible_distribution == 'FreeBSD' and ansible_distribution_version >= '11' ) -%}
78- MACs {{ ssh_macs_66_default | join(',') }}
79- {% elif ansible_os_family in ['Oracle Linux' , 'RedHat' ] and ansible_distribution_major_version <= '6' -%}
80- MACs {{ ssh_macs_53_default | join(',') }}
81- {% else -%}
82- MACs {{ ssh_macs_59_default | join(',') }}
83- {% endif %}
84- {% endif %}
59+ {{ "MACs "+ssh_macs| join(',') if ssh_macs else "MACs"|comment }}
8560
8661# Alternative setting, if OpenSSH version is below v5.9
8762#MACs hmac-ripemd160
@@ -90,21 +65,8 @@ LogLevel VERBOSE
9065# Weak kex is sometimes required if older package versions are used
9166# eg ruby's Net::SSH at around 2.2.* doesn't support sha2 for kex, so this will have to be set true in this case.
9267# based on: https://bettercrypto.org/static/applied-crypto-hardening.pdf
93- {% if (ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '14.04' ) or (ansible_distribution == 'Debian' and ansible_distribution_version >= '8' ) or (ansible_os_family in ['Oracle Linux' , 'RedHat' ] and ansible_distribution_major_version >= '7' ) or (ansible_distribution == 'FreeBSD' and ansible_distribution_version >= '11' ) -%}
94- {% if ssh_server_weak_kex -%}
95- KexAlgorithms {{ ssh_kex_66_weak | join(',') }}
96- {% else -%}
97- KexAlgorithms {{ ssh_kex_66_default | join(',') }}
98- {% endif %}
99- {% else -%}
100- {% if ansible_os_family in ['Oracle Linux' , 'RedHat' ] and ansible_distribution_major_version <= '6' -%}
101- #KexAlgorithms
102- {% elif ssh_server_weak_kex -%}
103- KexAlgorithms {{ sshd_kex_59_weak | join(',') }}
104- {% else -%}
105- KexAlgorithms {{ ssh_kex_59_default | join(',') }}
106- {% endif %}
107- {% endif %}
68+
69+ {{ "KexAlgorithms "+ssh_kex| join(',') if ssh_kex else "KexAlgorithms"|comment }}
10870
10971# Authentication
11072# --------------
@@ -275,3 +237,4 @@ Match User {{ item.user }}
275237 {{ item.rules | indent(4) }}
276238{% endfor %}
277239{% endif %}
240+
0 commit comments