On This Page
RHEL/CentOS 7 SSH Hardening
Description
Hardening the configuration of the SSH server is an important step in hardening your server. We recommend that you harden SSH as described below.
Relevant to
- CentOS 7.x or RHEL 7.x - all versions
Prerequisites
TOS must be installed on the server prior to implementing this resolution.
Notes
You will have to restart the sshd service after making the recommended changes. The service restart is included in the resolution steps below.
Resolution
-
Edit the file
/etc/ssh/sshd_config, and set the fields listed below to the values listed. You may have to delete the comment character ('#') from some entries.X11Forwarding no
Banner /etc/banner
ClientAliveInterval 3600
ClientAliveCountMax 0
AllowAgentForwarding no
AllowTcpForwarding no -
In the file
/etc/ssh/sshd_config, if the settingKexAlgorithmsexists, remove the valuediffie-hellman-group1-sha1and add the following values:diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256
-
In the file
/etc/ssh/sshd_config, if the settingKexAlgorithmsdid not exist, add the settingKexAlgorithmswith the following value:KexAlgorithms diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256
-
Restart the sshd service:
#
systemctl restart sshd -
Install all official security patches and updates released by the Linux distribution.