-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: SSH Client fails handshake when using publickey method #66438
Comments
@golang/security |
Quick not about findings from the issue over at ssh2 (the Node.js SSH2 server library). When switching from RSA to ED25519 keys, the handshake works as expected. So seems the issue is related to RSA keys somehow. |
Change https://go.dev/cl/573360 mentions this issue: |
@0x7f thank you for providing a reproducer. I think the linked CL fixes the reported issue. Can you please confirm? According to RFC 4252 Section 7 the algorithm in SSH_MSG_USERAUTH_REQUEST should match that of the request, so our code was correct, but some server send the key type instead. OpenSSH checks the key type (maybe to avoid problems with these buggy servers) so I think we should do the same |
I ran into this problem too. Through some gross debugging I found that it was failing here. My public key algo was I managed to get around it by changing the code (I forked the repo to unblock myself) to check if the algo matched any of the algos returned in |
Can you please confirm that this issue is fixed by applying this CL? Thank you |
@drakkan the CL fixes it for me 👍 Thanks a lot. I had trouble referencing the CL in my test project, so I manually applied the changes to the local code in $GOPATH. |
@drakkan any updates on this one? I'm not familiar with Gerrit, but to me it looks like the CL was not merged yet, right? |
It is in the review queue. It should be merged soon, I think another Google employee should approve it |
According to RFC 4252 Section 7 the algorithm in SSH_MSG_USERAUTH_PK_OK should match that of the request but some servers send the key type instead. OpenSSH checks for the key type, so we do the same. Fixes golang/go#66438 Fixes golang/go#64785 Fixes golang/go#56342 Fixes golang/go#54027 Change-Id: I2f733f0faece097e44ba7a97c868d30a53e21d79 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/573360 Auto-Submit: Nicola Murino <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Run-TryBot: Nicola Murino <[email protected]> Reviewed-by: Roland Shoemaker <[email protected]> Reviewed-by: Filippo Valsorda <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Joedian Reid <[email protected]>
I encountered a similar issue. My Go version is go1.21.9 and crypto is v0.30.0. I fixed it during debugging by specifying the key . My situation involves accessing OpenSSH_8.8 from OpenSSH_7.4.
|
Go version
go version go1.22.1 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
I'm building a SSH server using the Node.js library https://github.com/mscdex/ssh2 and I'm building the SSH client using the
x/crypto/ssh
library. The client aborts the SSH handshake when using thepublickey
authentication method.I built an example project including server and client here: https://github.com/0x7f/ssh-authentication-bug
What did you see happen?
Even though the server offers
[publickey]
authentication methods when initiating the handshake with authentication methodnone
, the client fails to connect. The client uses thepublickey
method and offers the key, and the server accepts the key, but the client still prints the error:What did you expect to see?
When using OpenSSH client, it connects successfully. I would expect the same from the Golang x/crypto/ssh client.
Maybe related to #64785
The text was updated successfully, but these errors were encountered: