Как 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?
2 ответа на вопрос
5
Thomas
Заказ выбирается клиентом с помощью HostKeyAlgorithmsопции конфигурации. По умолчанию в моей системе (согласно man-странице):
ecdsa-sha2-nistp256-cert-v01@openssh.com
ecdsa-sha2-nistp384-cert-v01@openssh.com
ecdsa-sha2-nistp521-cert-v01@openssh.com
ssh-ed25519-cert-v01@openssh.com
ssh-rsa-cert-v01@openssh.com
ssh-dss-cert-v01@openssh.com
ssh-rsa-cert-v00@openssh.com
ssh-dss-cert-v00@openssh.com
ECDSA-SHA2-nistp256
ECDSA-SHA2-nistp384
ECDSA-SHA2-nistp521
SSH-ed25519
SSH-RSA
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).
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