-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/crypto/ssh/knownhosts: can't verify host key if host certificate is sent #33366
Comments
I think this happens due to https://github.com/golang/crypto/blob/dab2b10/ssh/certs.go#L304 not checking |
/cc @FiloSottile |
Hi, I encountered this issue and found that this patch fixes it. It would fallback to verify if !c.IsHostAuthority(cert.SignatureKey, addr) {
+ if c.HostKeyFallback != nil {
+ err := c.HostKeyFallback(addr, remote, cert.Key)
+ if err != nil {
+ return fmt.Errorf("ssh: no authorities for hostname %v. retry with plain key but failed: %v", addr, err)
+ } else {
+ return nil
+ }
+ }
return fmt.Errorf("ssh: no authorities for hostname: %v", addr)
} If this is the correct way to fix, I can add some tests to it and open a PR. |
Faced with the same problem. Research lead to similar solution as @Bogay described. But with small corrections:
|
But in this approach, we don't provide any additional information that the fallback is being used (i.e., what I added with
|
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Write the following single line to a file called
known_hosts
:Run the following Go code (in the same directory so that it finds the file or change the path accordingly):
What did you expect to see?
The host key can be verified successfully.
Due to the minimal example which omits any authentication, there will also be an error in the successful case, but a different one:
Note that the connection works fine if the
HostKeyAlgorithms
from the code is uncommitted, which disables requesting host certificates. I found this behavior quite surprising and it took me some time to figure this out. Also this is inconsistent with OpenSSH which, if it receives a host certificate, seems to extract the host public key from it and also check this against the known hosts file.What did you see instead?
The host key can't be verified and the program exits with this error message:
The text was updated successfully, but these errors were encountered: