当前位置:   article > 正文

How To Resolve SSH Weak Key Exchange Algorithms on CentOS7 or RHEL7

How To Resolve SSH Weak Key Exchange Algorithms on CentOS7 or RHEL7

Introduction

On October 13, 2021, Tenable published the following SSH Vulnerability: SSH weak key exchange algorithms enabled  giving it a low severity rating. This does not mean it can’t be elevated to a medium or a high severity rating in the future. Also, the fix for this SSH vulnerability requires a simple change to the /etc/ssh/sshd_config file.  

According to Tenable, when the remote SSH server allows weak key exchange algorithms, it is considered weak. They are explicit about the entries recommended according to Section 4 of the Internet Engineering Task Force (IETF) draft document Key Exchange (KEX) Method Updates and Recommendations for Secure Shell (SSH) draft-ietf-curdle-ssh-kex-sha2-20. 

The following steps (below) will resolve this finding as well as, a related SSH finding which requires disabling cipher block chaining. Refer to Tenable SSH Server Cipher Block Chaining (CBC) Mode Ciphers Enabled for more details.

SSH Weak Key Exchange: Installation and Configuration

First things first, ensure your SSH version is up-to-date. 

  1. [root@localhost ~]# yum update *ssh* -y
  2. Last metadata expiration check: 0:42:36 ago on Wed 17 Nov 2021 04:59:46 AM UTC.
  3. Dependencies resolved.
  4. Nothing to do. Complete!

Next, run the following commands to list the available Ciphers and MACs for your SSH version.

Check Ciphers

  1. [root@localhost ~]# ssh -Q cipher
  2. 3des-cbc
  3. aes128-cbc
  4. aes192-cbc
  5. aes256-cbc
  6. rijndael-cbc@lysator.liu.se
  7. aes128-ctr
  8. aes192-ctr
  9. aes256-ctr
  10. aes128-gcm@openssh.com
  11. aes256-gcm@openssh.com
  12. chacha20-poly1305@openssh.com

Check MACs

  1. [root@tech ~]# ssh -Q mac
  2. hmac-sha1
  3. hmac-sha1-96
  4. hmac-sha2-256
  5. hmac-sha2-512
  6. hmac-md5
  7. hmac-md5-96
  8. umac-64@openssh.com
  9. umac-128@openssh.com
  10. hmac-sha1-etm@openssh.com
  11. hmac-sha1-96-etm@openssh.com
  12. hmac-sha2-256-etm@openssh.com
  13. hmac-sha2-512-etm@openssh.com
  14. hmac-md5-etm@openssh.com
  15. hmac-md5-96-etm@openssh.com
  16. umac-64-etm@openssh.com
  17. umac-128-etm@openssh.com

Examine the list as we’re not going to use all that is listed here (above). We just need to ensure that we DO NOT choose anything with sha1 in our final entry. Here’s an example of how your final entry for Ciphers, KexAlogrithms, and MACs might look like this (below) (No space between commas):

  1. Ciphers aes128-ctr,aes192-ctr,aes256-ctr
  2. KexAlgorithms ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256
  3. MACs hmac-sha2-256,hmac-sha2-512

Copy and paste the following entries (above) to the end or bottom of the /etc/ssh/sshd_config file and restart the ssh daemon or service.

[root@localhost ~]# systemctl restart sshd.service

SSH Weak Key Exchange: Testing

SSH to localhost with verbosity to see if the change is applied and working. 

  1. [root@tech ~]# ssh -vvvv localhost
  2. OpenSSH_8.0p1, OpenSSL 1.1.1k FIPS 25 Mar 2021
  3. debug1: Reading configuration data /etc/ssh/ssh_config
  4. debug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0
  5. debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
  6. debug2: checking match for 'final all' host localhost originally localhost
  7. debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: not matched 'final'
  8. debug2: match not found
  9. debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1 (parse only)
  10. debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
  11. debug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-]
  12. debug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]
  13. debug1: configuration requests final Match pass
  14. debug1: re-parsing configuration
  15. debug1: Reading configuration data /etc/ssh/ssh_config
  16. debug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0

As you can see (above), the change was applied successfully!

Conclusion

Remember, the specific steps may vary depending on your operating system and SSH version. Always refer to the documentation for your specific implementation for accurate and detailed instructions. Finally, if you’re looking to automate this procedure, here’s a post that can help you with that!

Was this article helpful to you? If so, leave us a comment below. We’d love to hear from you!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/486833
推荐阅读
相关标签
  

闽ICP备14008679号