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

Commit 6c39725

Browse files
Sebastian GumprichSebastian Gumprich
authored andcommitted
add bool checks to all relevant variables
1 parent a58fb13 commit 6c39725

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

templates/opensshd.conf.j2

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# ===================
88

99
# Either disable or only allowssh root login via certificates.
10-
PermitRootLogin {% if ssh_allow_root_with_key|bool %} without-password {% else %} no {% endif %}
10+
PermitRootLogin {% if (ssh_allow_root_with_key|bool) %} without-password {% else %} no {% endif %}
1111
#PermitRootLogin {{ 'without-password' if ssh_allow_root_with_key else 'no' | bool }}
1212

1313
# Define which port sshd should listen to. Default to `22`.
@@ -16,7 +16,7 @@ Port {{port}}
1616
{% endfor %}
1717

1818
# Address family should always be limited to the active network configuration.
19-
AddressFamily {{ 'any' if network_ipv6_enable else 'inet' }}
19+
AddressFamily {{ 'any' if (network_ipv6_enable|bool) else 'inet' }}
2020

2121
# Define which addresses sshd should listen to. Default to `0.0.0.0`, ie make sure you put your desired address in here, since otherwise sshd will listen to everyone.
2222
{% for address in ssh_listen_to -%}
@@ -128,12 +128,12 @@ IgnoreUserKnownHosts yes
128128
HostbasedAuthentication no
129129

130130
# Enable PAM to enforce system wide rules
131-
UsePAM {{ 'yes' if ssh_use_pam else 'no' }}
131+
UsePAM {{ 'yes' if (ssh_use_pam|bool) else 'no' }}
132132

133133
# Disable password-based authentication, it can allow for potentially easier brute-force attacks.
134-
PasswordAuthentication {{ 'yes' if ssh_server_password_login else 'no' }}
134+
PasswordAuthentication {{ 'yes' if (ssh_server_password_login|bool) else 'no' }}
135135
PermitEmptyPasswords no
136-
ChallengeResponseAuthentication {{ 'yes' if ssh_challengeresponseauthentication else 'no' }}
136+
ChallengeResponseAuthentication {{ 'yes' if (ssh_challengeresponseauthentication|bool) else 'no' }}
137137

138138
# Only enable Kerberos authentication if it is configured.
139139
KerberosAuthentication no
@@ -173,15 +173,15 @@ ClientAliveInterval {{ssh_client_alive_interval}}
173173
ClientAliveCountMax {{ssh_client_alive_count}}
174174

175175
# Disable tunneling
176-
PermitTunnel {{ 'yes' if ssh_permit_tunnel else 'no' }}
176+
PermitTunnel {{ 'yes' if (ssh_permit_tunnel|bool) else 'no' }}
177177

178178
# Disable forwarding tcp connections.
179179
# no real advantage without denied shell access
180-
AllowTcpForwarding {{ 'yes' if ssh_allow_tcp_forwarding else 'no' }}
180+
AllowTcpForwarding {{ 'yes' if (ssh_allow_tcp_forwarding|bool) else 'no' }}
181181

182182
# Disable agent formwarding, since local agent could be accessed through forwarded connection.
183183
# no real advantage without denied shell access
184-
AllowAgentForwarding {{ 'yes' if ssh_allow_agent_forwarding else 'no' }}
184+
AllowAgentForwarding {{ 'yes' if (ssh_allow_agent_forwarding|bool) else 'no' }}
185185

186186
# Do not allow remote port forwardings to bind to non-loopback addresses.
187187
GatewayPorts no
@@ -205,20 +205,20 @@ PermitUserEnvironment no
205205
# Misc. configuration
206206
# ===================
207207

208-
Compression {{ 'yes' if ssh_compression else 'no' }}
208+
Compression {{ 'yes' if (ssh_compression|bool) else 'no' }}
209209

210-
UseDNS {{ 'yes' if ssh_use_dns else 'no' }}
210+
UseDNS {{ 'yes' if (ssh_use_dns|bool) else 'no' }}
211211

212-
PrintMotd {{ 'yes' if ssh_print_motd else 'no' }}
212+
PrintMotd {{ 'yes' if (ssh_print_motd|bool) else 'no' }}
213213

214214
{% if ansible_os_family != 'FreeBSD' %}
215-
PrintLastLog {{ 'yes' if ssh_print_last_log else 'no' }}
215+
PrintLastLog {{ 'yes' if (ssh_print_last_log|bool) else 'no' }}
216216
{% endif %}
217217

218-
Banner {{ '/etc/ssh/banner.txt' if ssh_banner else 'none' }}
218+
Banner {{ '/etc/ssh/banner.txt' if (ssh_banner|bool) else 'none' }}
219219

220220
{% if ansible_os_family == 'Debian' %}
221-
DebianBanner {{ 'yes' if ssh_print_debian_banner else 'no' }}
221+
DebianBanner {{ 'yes' if (ssh_print_debian_banner|bool) else 'no' }}
222222
{% endif %}
223223

224224
# Reject keys that are explicitly blacklisted

0 commit comments

Comments
 (0)