x/crypto/ssh: "ssh-rsa-cert-v01@openssh.com" does not work for sshd OpenSSH 7.2-7.7 #58371
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
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?
I have an OpenSSH server version 7.4p1.
I have the below program which works with
golang.org/x/crypto/ssh
in Go version 1.17 but not the latest tagged version0.5.0
.main.go
CodeWhat did you expect to see?
I expect it to dial successfully as it did in previous versions 0.4.0.
What did you see instead?
Debugging and Root Cause
After investigating to try and understand what was the issue, I found the following behavior.
OpenSSH 7.2: Supports
rsa-sha2-256/512
alternatives, and shares those two with the clientOpenSSH 7.8: Adds support for the certificate versions of
rsa-sha2-256
which arersa-sha2-256-cert-v01@openssh.com
andrsa-sha2-512-cert-v01@openssh.com
. Important to note that the server does not broadcast these.In the latest code, the server's
SSH_MSG_EXT_INFO
contains onlyrsa-sha2-256
without the certificate variants, which is why the code correctly adds those to the list of supported for those versions.However, this breaks the fallback mechanisms if the client is using
ssh-rsa-cert-v01@openssh.com
, because it incorrectly identifies the server as supporting SHA2 certificates, when in reality it only supports SHA2 keys. Because of this, the client tries to get the key verified with the server, and the server rejects it which causes the permission denied error. What should happen is the client still tries the SHA1 certificate if the SHA2 one fails.Because the library does not support any kind of configuring of signatures, I reproduced it with OpenSSH client:
Output
Manually adding support for certificate:
Related
#56342 - seems to be a similar result, but different root causes
The text was updated successfully, but these errors were encountered: