O arquivo known_hosts é para fornecer essas chaves e não há nenhuma alternativa de linha de comando direta (e de qualquer forma não seria tão útil). No entanto, seu objetivo é completamente possível com o arquivo known_hosts !
Leia o % formato de arquivo man sshd do ssh_known_hosts .
When performing host authentication, authentication is accepted if any matching line has the proper key; either one that matches exactly or, if the server has presented a certificate for authentication, the key of the certification authority that signed the certificate.
É possível usar curingas em ~/.ssh/known_hosts (e /etc/ssh/ssh_known_hosts ):
Each line in these files contains the following fields: markers (optional), hostnames, keytype, base64-encoded key, comment. The fields are separated by spaces.
Hostnames is a comma-separated list of patterns (
*and?act as wildcards); each pattern in turn is matched against the canonical host name (when authenticating a client) or against the user-supplied name (when authenticating a server). A pattern may also be preceded by!to indicate negation: if the host name matches a negated pattern, it is not accepted (by that line) even if it matched another pattern on the line. A hostname or address may optionally be enclosed within[and]brackets then followed by ‘:’ and a non-standard port number.
É possível tornar uma chave confiável para
-
um intervalo de rede, se conhecido, por ex. para
TEST-NET-2:198.51.100.* ssh-rsa AAAAB3Nza...2iQ== -
vários intervalos (por exemplo, todos os
TEST-NETs) usando a lista separada por vírgulas:192.0.2.*,198.51.100.*,203.0.113.* ssh-rsa AAAAB3Nza...2iQ== -
ou até mesmo quando se conecta em qualquer lugar:
* ssh-rsa AAAAB3Nza...2iQ==
Se essa chave não estiver presente, ela ainda avisará sobre a autenticidade das outras chaves, mostrará a impressão digital e a adicionará automaticamente, se você responder yes . A comparação é feita linha a linha.