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

Commit ab64f11

Browse files
committed
Add 'all', 'local', 'yes', 'no' options support for AllowTcpForwarding variable
1 parent 21e442c commit ab64f11

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Warning: This role disables root-login on the target server! Please make sure yo
2727
|`ssh_permit_tunnel` | false | true if SSH Port Tunneling is required |
2828
|`ssh_remote_hosts` | [] | one or more hosts and their custom options for the ssh-client. Default is empty. See examples in `defaults/main.yml`.|
2929
|`ssh_permit_root_login` | no | Disable root-login. Set to `without-password` or `yes` to enable root-login |
30-
|`ssh_allow_tcp_forwarding` | false | false to disable TCP Forwarding. Set to true to allow TCP Forwarding.|
30+
|`ssh_allow_tcp_forwarding` | false | false to disable TCP Forwarding. Set to true to allow TCP Forwarding. If you are using OpenSSH >= 6.2 version, you should specify `yes`, `no`, `all` or `local` otherwise it will fallback to default value|
3131
|`ssh_gateway_ports` | `false` | `false` to disable binding forwarded ports to non-loopback addresses. Set to `true` to force binding on wildcard address. Set to `clientspecified` to allow the client to specify which address to bind to.|
3232
|`ssh_allow_agent_forwarding` | false | false to disable Agent Forwarding. Set to true to allow Agent Forwarding.|
3333
|`ssh_pam_support` | true | true if SSH has PAM support.|

templates/opensshd.conf.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,11 @@ PermitTunnel {{ 'yes' if (ssh_permit_tunnel|bool) else 'no' }}
174174

175175
# Disable forwarding tcp connections.
176176
# no real advantage without denied shell access
177+
{% if sshd_version.stdout is version('6.2', '>=') %}
178+
AllowTcpForwarding {{ ssh_allow_tcp_forwarding if (ssh_allow_tcp_forwarding in ('yes', 'no', 'local', 'all')) else 'no' }}
179+
{% else %}
177180
AllowTcpForwarding {{ 'yes' if (ssh_allow_tcp_forwarding|bool) else 'no' }}
181+
{% endif %}
178182

179183
# Disable agent forwarding, since local agent could be accessed through forwarded connection.
180184
# no real advantage without denied shell access

tests/default_custom.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
- ansible-ssh-hardening
2424
vars:
2525
network_ipv6_enable: true
26-
ssh_allow_tcp_forwarding: true
26+
ssh_allow_tcp_forwarding: 'local'
2727
ssh_gateway_ports: true
2828
ssh_allow_agent_forwarding: true
2929
ssh_server_permit_environment_vars: 'yes'

0 commit comments

Comments
 (0)