Skip to content

Commit 4ae5acf

Browse files
committed
move Match Group sftponly block to the end
Signed-off-by: Michael <[email protected]>
1 parent 0a52f91 commit 4ae5acf

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

roles/ssh_hardening/README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ For more information, see [this issue](https://github.com/dev-sec/ansible-collec
8989
- Description: Specifies the umask for sftp.
9090
- Type: str
9191
- Required: no
92-
- `sftp_password_login`
93-
- Default: inherite from `ssh_server_password_login`
94-
- Description: Set to `true` to allow password-based authentication to the sftp server. You probably also need to change `sshd_authenticationmethods` to include `password` if you set `sftp_password_login`: `true`.
95-
- Type: bool
96-
- Required: no
9792
- `ssh_allow_agent_forwarding`
9893
- Default: `False`
9994
- Description: Set to `false` to disable Agent Forwarding. Set to `true` to allow Agent Forwarding.

roles/ssh_hardening/defaults/main.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@ sftp_umask: "0027"
180180
# change default sftp chroot location
181181
sftp_chroot_dir: /home/%u
182182

183-
# If true, password login for sftp is allowed
184-
sftp_password_login: "{{ ssh_server_password_login }}"
185-
186183
# enable experimental client roaming
187184
ssh_client_roaming: false
188185

roles/ssh_hardening/templates/opensshd.conf.j2

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -274,18 +274,6 @@ RevokedKeys /etc/ssh/revoked_keys
274274
# Subsystem sftp /opt/app/openssh5/libexec/sftp-server
275275

276276
Subsystem sftp internal-sftp -l INFO -f LOCAL6 -u {{ sftp_umask }}
277-
278-
# These lines must appear at the *end* of sshd_config
279-
Match Group sftponly
280-
ForceCommand internal-sftp -l INFO -f LOCAL6 -u {{ sftp_umask }}
281-
{% if sftp_chroot %}
282-
ChrootDirectory {{ sftp_chroot_dir }}
283-
{% endif %}
284-
AllowTcpForwarding no
285-
AllowAgentForwarding no
286-
PasswordAuthentication {{ 'yes' if (sftp_password_login|bool) else 'no' }}
287-
PermitRootLogin no
288-
X11Forwarding no
289277
{% endif %}
290278
{% if ssh_server_match_address %}
291279

@@ -335,3 +323,17 @@ Match LocalPort {{ item.port }}
335323
{% endfor %}
336324
{% endfor %}
337325
{% endif %}
326+
327+
{% if sftp_enabled %}
328+
# These lines must appear at the *end* of sshd_config
329+
Match Group sftponly
330+
ForceCommand internal-sftp -l INFO -f LOCAL6 -u {{ sftp_umask }}
331+
{% if sftp_chroot %}
332+
ChrootDirectory {{ sftp_chroot_dir }}
333+
{% endif %}
334+
AllowTcpForwarding no
335+
AllowAgentForwarding no
336+
PasswordAuthentication {{ 'yes' if (ssh_server_password_login|bool) else 'no' }}
337+
PermitRootLogin no
338+
X11Forwarding no
339+
{% endif %}

0 commit comments

Comments
 (0)