Description
Proposal Details
If ClientConfig.HostKeyAlgorithms
is not set, a reasonable default is set for acceptable host key type, which may be one for which you do not have a matching host key provided using ClientConfig.HostKeyCallback
.
If our users don't set ClientConfig.HostKeyAlgorithms
we should try to obtain the expected algorithms from the configured ClientConfig.HostKeyCallback
.
To enable this automatic detection, I propose to add a new error that HostKeyCallback
implementations can return to inform about supported algorithms:
// HostKeyCallbackError may be returned from [HostKeyCallback] implementations
// to inform about supported host key algorithms. If no [ClientConfig]
// HostKeyAlgorithms are set, the [Client] will execute the callback with a
// non-existent key type to discover and use the expected algorithms. For
// ssh-rsa key format we suggest returning sha-2 variants of the algorithms.
type HostKeyCallbackError struct {
// HostKeyAlgorithms lists the public key algorithms that the callback will
// accept.
HostKeyAlgorithms []string
}
It is preferable to return HostKeyAlgorithms
and not the key formats because this way implementations can decide, for example, to return only the sha-2 variants for the ssh-rsa
key format.
if ClientConfig.HostKeyAlgorithms
is not set, our client will execute the callback passing a sentinel, non-existent, key type and, if the error returned is an HostKeyCallbackError
, the returned host key algorithms are used.
We should return HostKeyCallbackError
in our internal HostKeyCallback
implementations:
- ssh.FixedHostKey
- knownhosts.New
Metadata
Metadata
Assignees
Type
Projects
Status