How To Disable diffie-hellman-group1-sha1 for SSH

I have found that my server via SSH still supports diffie-hellman-group1-sha1. To stay compliant with latest PCI Compliance I have been trying to figure out how to disable diffie-hellman-group1-sha1. Weakdh.org doesn't exactly give clear instructions on how to disable this nor anything on the web. What is the proper way to disable this algorithm without disabling Port 22 for SSH on Ubuntu? Below is what algorithms my server supports when running ssh -Q kex.

diffie-hellman-group1-sha1
diffie-hellman-group14-sha1
diffie-hellman-group-exchange-sha1
diffie-hellman-group-exchange-sha256
ecdh-sha2-nistp256
ecdh-sha2-nistp384
ecdh-sha2-nistp521
diffie-hellman-group1-sha1
curve25519-sha256@libssh.org
6
задан 21 February 2016 в 01:22
3 ответа

запуск ssh -Q kex

дает вам список клиентов поддерживаемые алгоритмы. Серверные вы получите от sshd -T | grep kex (на сервере, конечно).

И если вы хотите удалить его, просто возьмите список, полученный из предыдущей команды, удалите интересующий вас алгоритм и поместите его в / etc / ssh / sshd_config (или замените там существующую строку алгоритмами kex).

3
ответ дан 3 December 2019 в 00:15

man sshd_config

 KexAlgorithms
         Specifies the available KEX (Key Exchange) algorithms.  Multiple algorithms must be comma-separated.  The default is

               curve25519-sha256@libssh.org,
               ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,
               diffie-hellman-group-exchange-sha256,
               diffie-hellman-group-exchange-sha1,
               diffie-hellman-group14-sha1,
               diffie-hellman-group1-sha1

Итак, чтобы отключить "diffie-hellman-group1-sha1", укажите необходимые алгоритмы с параметром KexAlgorithms

Пример

KexAlgorithms (скрыто)

7
ответ дан 3 December 2019 в 00:15

В OpenSSH 7.6, если вы хотите удалить один или несколько параметров и оставить остальные значения по умолчанию, вы можете добавить следующую строку в /etc/ssh/sshd_config:

KexAlgorithms -diffie-hellman-group1-sha1,ecdh-sha2-nistp256

Обратите внимание на - в начале списка, разделенного запятыми. Приведенная выше строка отключит diffie-hellman-group1-sha1 и ecdh-sha2-nistp256.

Это подробно описано в man sshd_config в разделе KexAlgorithms:

If the specified value begins with a ‘-’ character, then the specified methods (including
wildcards) will be removed from the default set instead of replacing them.

И последнее замечание: после внесения любых изменений в /etc/ssh/sshd_config всегда проверьте их с помощью sshd -t перед перезапуском sshd.

3
ответ дан 26 November 2020 в 12:49

Теги

Похожие вопросы