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

Commit

Permalink
Merge pull request #257 from brnck/tcp_options
Browse files Browse the repository at this point in the history
Add 'all', 'local', 'yes', 'no' options support for AllowTcpForwarding variable
  • Loading branch information
rndmh3ro committed Dec 1, 2019
2 parents 21e442c + b0139c7 commit d1824a8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Warning: This role disables root-login on the target server! Please make sure yo
|`ssh_permit_tunnel` | false | true if SSH Port Tunneling is required |
|`ssh_remote_hosts` | [] | one or more hosts and their custom options for the ssh-client. Default is empty. See examples in `defaults/main.yml`.|
|`ssh_permit_root_login` | no | Disable root-login. Set to `without-password` or `yes` to enable root-login |
|`ssh_allow_tcp_forwarding` | false | false to disable TCP Forwarding. Set to true to allow TCP Forwarding.|
|`ssh_allow_tcp_forwarding` | no | `no` to disable TCP Forwarding. Set to `yes` to allow TCP Forwarding. If you are using OpenSSH >= 6.2 version, you can specify `yes`, `no`, `all` or `local`|
|`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.|
|`ssh_allow_agent_forwarding` | false | false to disable Agent Forwarding. Set to true to allow Agent Forwarding.|
|`ssh_pam_support` | true | true if SSH has PAM support.|
Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ssh_remote_hosts: []
ssh_permit_root_login: 'no' # sshd

# false to disable TCP Forwarding. Set to true to allow TCP Forwarding.
ssh_allow_tcp_forwarding: false # sshd
ssh_allow_tcp_forwarding: 'no' # sshd

# 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.
Expand Down
6 changes: 5 additions & 1 deletion templates/opensshd.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ PermitTunnel {{ 'yes' if (ssh_permit_tunnel|bool) else 'no' }}

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

# Disable agent forwarding, since local agent could be accessed through forwarded connection.
# no real advantage without denied shell access
Expand Down
2 changes: 1 addition & 1 deletion tests/default_custom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
- ansible-ssh-hardening
vars:
network_ipv6_enable: true
ssh_allow_tcp_forwarding: true
ssh_allow_tcp_forwarding: 'yes'
ssh_gateway_ports: true
ssh_allow_agent_forwarding: true
ssh_server_permit_environment_vars: 'yes'
Expand Down

0 comments on commit d1824a8

Please sign in to comment.