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

Commit 5a96607

Browse files
authored
Merge pull request #136 from pwyliu/configure-gateway-ports
allow configuration of GatewayPorts
2 parents 0c8fd63 + a0c330e commit 5a96607

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Warning: This role disables root-login on the target server! Please make sure yo
3434
|`ssh_remote_hosts` | [] | one or more hosts and their custom options for the ssh-client. Default is empty. See examples in `defaults/main.yml`.|
3535
|`ssh_allow_root_with_key` | false | false to disable root login altogether. Set to true to allow root to login via key-based mechanism.|
3636
|`ssh_allow_tcp_forwarding` | false | false to disable TCP Forwarding. Set to true to allow TCP Forwarding.|
37+
|`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.|
3738
|`ssh_allow_agent_forwarding` | false | false to disable Agent Forwarding. Set to true to allow Agent Forwarding.|
3839
|`ssh_use_pam` | false | false to disable pam authentication.|
3940
|`ssh_deny_users` | '' | if specified, login is disallowed for user names that match one of the patterns.|

default.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
network_ipv6_enable: true
2424
ssh_allow_root_with_key: true
2525
ssh_allow_tcp_forwarding: true
26+
ssh_gateway_ports: true
2627
ssh_allow_agent_forwarding: true
2728
ssh_server_permit_environment_vars: ['PWD','HTTP_PROXY']
2829
ssh_client_alive_interval: 100

defaults/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ ssh_allow_root_with_key: false # sshd
6666
# false to disable TCP Forwarding. Set to true to allow TCP Forwarding.
6767
ssh_allow_tcp_forwarding: false # sshd
6868

69+
# false to disable binding forwarded ports to non-loopback addresses. Set to true to force binding on wildcard address.
70+
# Set to 'clientspecified' to allow the client to specify which address to bind to.
71+
ssh_gateway_ports: false # sshd
72+
6973
# false to disable Agent Forwarding. Set to true to allow Agent Forwarding.
7074
ssh_allow_agent_forwarding: false # sshd
7175

templates/opensshd.conf.j2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,16 @@ AllowTcpForwarding {{ 'yes' if (ssh_allow_tcp_forwarding|bool) else 'no' }}
186186
# no real advantage without denied shell access
187187
AllowAgentForwarding {{ 'yes' if (ssh_allow_agent_forwarding|bool) else 'no' }}
188188

189+
{% if ssh_gateway_ports|bool %}
190+
# Port forwardings are forced to bind to the wildcard address
191+
GatewayPorts yes
192+
{% elif ssh_gateway_ports == 'clientspecified' %}
193+
# Clients allowed to specify which address to bind port forwardings to
194+
GatewayPorts clientspecified
195+
{% else %}
189196
# Do not allow remote port forwardings to bind to non-loopback addresses.
190197
GatewayPorts no
198+
{% endif %}
191199

192200
# Disable X11 forwarding, since local X11 display could be accessed through forwarded connection.
193201
X11Forwarding no

0 commit comments

Comments
 (0)