-
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: "[email protected]" does not work for sshd OpenSSH 7.2-7.7 #58371
Comments
@golang/security can you give this a look? |
Hello, this is fixed with this CL, you can now do
or
both works. This is very similar to OpenSSH now, it works if you set the algorithm |
Looks promising, much appreciated! I'll give it a try once I get access to the box again. |
@drakkan using NewSignerWithAlgorithms to disable SHA-2 is a valid workaround, but it's a bit unfortunate to make it spread in the ecosystem. How does OpenSSH itself connect to these misbehaving OpenSSH 7.2-7.7? (This is a bug in OpenSSH 7.2-7.7, right? If advertising the underlying algorithm, the server must support the certificate one?) Is an automatic fallback (assuming SHA-1 is not disabled) an option? |
Change https://go.dev/cl/510155 mentions this issue: |
@masp, in the above CL I implemented an automatic fallback. @FiloSottile these versions of OpenSSH accept sha2 algorithms for public key authentication, only for certificates they are rejected. I hope this is the last edge case introduced with |
Hi @masp how did you repro this with openssh client: Can you help me understand what did you change to get the client that can repro this issue?
I want to understand how openssh client solved this issue, and I think if I understand how you repro this issue I could understand how they fixed it. Thanks for your time. |
Thanks @drakkan looks like that will solve the issue! Appreciate the fix! Hi @achal1012, it is certainly confusing, looking back at my notes I am trying to remember what I did as well. @drakkan can probably give a more in depth reason why it's failing, but I'll try my best to remember. I tested with the following: OpenSSH Client: OpenSSH Server: Closing the issue since the newest CL seems to fix it. |
Please re-open. The patch that fixes this issue has not yet been merged |
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 are[email protected]
and[email protected]
. 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
[email protected]
, 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: