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

Commit b7bc40b

Browse files
authored
Merge pull request #231 from MatthiasLohr/feature/MatchAddress
added support for `ssh_server_match_address` (#230)
2 parents 9076895 + b60fe1b commit b7bc40b

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Warning: This role disables root-login on the target server! Please make sure yo
6464
|`ssh_print_debian_banner` | `false` | `true` to print debian specific banner |
6565
|`ssh_server_enabled` | `true` | `false` to disable the opensshd server |
6666
|`ssh_server_hardening` | `true` | `false` to stop harden the server |
67+
|`ssh_server_match_address` | '' | Introduces a conditional block. If all of the criteria on the Match line are satisfied, the keywords on the following lines override those set in the global section of the config file, until either another Match line or the end of the file. |
6768
|`ssh_server_match_group` | '' | Introduces a conditional block. If all of the criteria on the Match line are satisfied, the keywords on the following lines override those set in the global section of the config file, until either another Match line or the end of the file. |
6869
|`ssh_server_match_user` | '' | Introduces a conditional block. If all of the criteria on the Match line are satisfied, the keywords on the following lines override those set in the global section of the config file, until either another Match line or the end of the file. |
6970
|`ssh_server_permit_environment_vars` | `false` | `true` to specify that ~/.ssh/environment and environment= options in ~/.ssh/authorized_keys are processed by sshd |

defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ ssh_server_match_user: false # sshd
151151
# list of hashes (containing group and rules) to generate Match Group blocks for.
152152
ssh_server_match_group: false # sshd
153153

154+
# list of hashes (containing addresses/subnets and rules) to generate Match Address blocks for.
155+
ssh_server_match_address: false # sshd
156+
154157
ssh_server_permit_environment_vars: false
155158

156159
# maximum number of concurrent unauthenticated connections to the SSH daemon

templates/opensshd.conf.j2

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,18 @@ Match Group sftponly
254254
X11Forwarding no
255255
{% endif %}
256256

257+
{% if ssh_server_match_address -%}
258+
# Address matching configuration
259+
# ============================
260+
261+
{% for item in ssh_server_match_address -%}
262+
Match Address {{ item.address }}
263+
{% for rule in item.rules %}
264+
{{ rule | indent(4) }}
265+
{% endfor %}
266+
{% endfor %}
267+
{% endif %}
268+
257269
{% if ssh_server_match_group -%}
258270
# Group matching configuration
259271
# ============================

tests/default_custom.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
sftp_enabled: true
4848
sftp_chroot: true
4949
#ssh_server_enabled: false
50+
ssh_server_match_address:
51+
- address: '192.168.1.1/24'
52+
rules:
53+
- 'AllowTcpForwarding yes'
54+
- 'AllowAgentForwarding no'
5055
ssh_server_match_group:
5156
- group: 'root'
5257
rules:

0 commit comments

Comments
 (0)