I'm using OpenSSH certificates for a pool of hosts. That is to say, in ~/.ssh/known_hosts
, there's an entry that looks thus:
@cert-authority service.redacted.com ssh-rsa ...
...and service.redacted.com
is a round-robin DNS entry for which each system involved has a host certificate (see the HostCertificate
entry in man sshd_config
) signed as valid for service.redacted.com
.
This works perfectly when wanting to connect to a randomly-selected system from the pool -- but what if someone wants to connect to a single, specific system from the pool, validating its host key as legitimate using the certificate authority given?
One thing I tried was thus:
service_name=service.redacted.com
specific_host=1.2.3.4
ssh -v -oHostKeyAlias="$service_name" "$specific_host"
...which results in the following:
debug1: Host 'service.redacted.com' is known and matches the RSA-CERT host certificate
Certificate invalid: name is not a listed principal
The authenticity of host 'service.redacted.com (1.2.3.4)' can't be established.
service.redacted.com
quite certainly is a listed principal in the certificate; 1.2.3.4
is not.
As of current upstream OpenSSH-portable master (https://github.com/openssh/openssh-portable/commits/773dda25e828c4c9a52f7bdce6e1e5924157beab), this is not possible.
The relevant logic is in the check_host_key() function, which calls
check_host_cert()
only once -- with the hostname which was originally passed intossh_login()
modified only by normalizing all characters to lowercase. That same hostname in passed throughresolve_host()
to get theaddrinfo *
struct used for the actual connection;resolve_host()
respects a few options (selecting the address family to use), but otherwise does not provide an override mechanism.That said, the change needed is a short one (presently submitted to the upstream mailing list and pending review):