Disable SSH TCP Forwarding
An XCCDF Rule
Description
The AllowTcpForwarding
parameter specifies whether TCP forwarding is permitted.
To disable TCP forwarding, add or correct the following line in
/etc/ssh/sshd_config.d/00-complianceascode-hardening.conf
:
AllowTcpForwarding no
Rationale
Leaving port forwarding enabled can expose the organization to security risks and back-doors.
- ID
- xccdf_org.ssgproject.content_rule_sshd_disable_tcp_forwarding
- Severity
- Medium
- References
- Updated
Remediation - Ansible
- name: Disable SSH TCP Forwarding
block:
- name: Deduplicate values from /etc/ssh/sshd_config
lineinfile:
path: /etc/ssh/sshd_config
Remediation - Shell Script
# Remediation is applicable only in certain platforms
if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; then
mkdir -p /etc/ssh/sshd_config.d
touch /etc/ssh/sshd_config.d/00-complianceascode-hardening.conf