Как OpenSSH решает, какой ключ хоста использовать?

3688
IQAndreas

По умолчанию в моей текущей версии ( 6.9p1) OpenSSH Server создает четыре типа ключей хоста:

$ ls /etc/ssh/ssh_host_*_key.pub /etc/ssh/ssh_host_dsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ed25519_key.pub /etc/ssh/ssh_host_rsa_key.pub 

В ходе тестирования я заметил, что, по крайней мере, при использовании той же версии клиента OpenSSH ( 6.9p1) ключ ECDSA будет использоваться хостом, независимо от типа ключа клиента.

Где OpenSSH решает, какой приоритет имеют поддерживаемые алгоритмы? Является ли эта информация редактируемой или жестко закодированной в исходный код текущей версии?

И что еще более важно, почему OpenSSH решил уделить первоочередное внимание алгоритму ECDSA?

5

2 ответа на вопрос

5
Thomas

Заказ выбирается клиентом с помощью HostKeyAlgorithmsопции конфигурации. По умолчанию в моей системе (согласно man-странице):

  1. ecdsa-sha2-nistp256-cert-v01@openssh.com
  2. ecdsa-sha2-nistp384-cert-v01@openssh.com
  3. ecdsa-sha2-nistp521-cert-v01@openssh.com
  4. ssh-ed25519-cert-v01@openssh.com
  5. ssh-rsa-cert-v01@openssh.com
  6. ssh-dss-cert-v01@openssh.com
  7. ssh-rsa-cert-v00@openssh.com
  8. ssh-dss-cert-v00@openssh.com
  9. ECDSA-SHA2-nistp256
  10. ECDSA-SHA2-nistp384
  11. ECDSA-SHA2-nistp521
  12. SSH-ed25519
  13. SSH-RSA
  14. SSH-ДСС

Чтобы переопределить это, сделайте что-то вроде:

ssh -oHostKeyAlgorithms=ssh-ed25519 user@foo.com

3
MariusMatutiae

And more importantly, why has OpenSSH decided give the ECDSA algorithm first priority?

ECDSA was introduced into openssh with version 5.7, you may find the Release notes here. In particular, it is stated:

Implement Elliptic Curve Cryptography modes for key exchange (ECDH) and host/user keys (ECDSA) as specified by RFC5656. ECDH and ECDSA offer better performance than plain DH and DSA at the same equivalent symmetric key length, as well as much shorter keys.

.......

Certificate host and user keys using the new ECDSA key types are supported - an ECDSA key may be certified, and an ECDSA key may act as a CA to sign certificates.

ECDH in a 256 bit curve field is the preferred key agreement algorithm when both the client and server support it. ECDSA host keys are preferred when learning a host's keys for the first time, or can be learned using ssh-keyscan(1).

Also, RFC 5656 states:

Many estimates consider that 2^80-2^90 operations are beyond feasible, so that would suggest using elliptic curves of at least 160-180 bits. The REQUIRED curves in this document are 256-, 384-, and 521-bit curves; implementations SHOULD NOT use curves smaller than 160 bits

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