-
Notifications
You must be signed in to change notification settings - Fork 18k
x/crypto/ssh: SSH handshake fails over some net.Conn implementations (ex. net.Pipe) #32990
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
Comments
CC @hanwen |
yes, don't do this. This is the reason why the SSH package has a netPipe function, see if this a defect, then it is a defect in net.Pipe. There is no way to make a SSH connection that doesn't start with both sides writing simultaneously. |
Thanks for the quick response.
I totally get where you are coming from with this, but let me play devils advocate for a moment. If you can have a correct implementation of a One way around this would be to require a TCPConn instead perhaps? At the vary least I think this caveat needs to be added to the comments for any exported functions or method that accept a
While its simple enough to re-implement, I think you should consider exporting Thanks! |
TCPConn is a concrete type, and I think it is better if the SSH accepts an interface. However, interfaces are just a collection of methods, and behaviors such as the one we're interested in here can't be encoded in an interface. I think it would be useful to have a in-memory connection that allows writes from both sides, but I'll leave that up to the core Go team to decide where that should be. In any case, I think it is wrong for the SSH package to provide this as a utility. |
#24205 seems closely related. |
@hanwen, I would argue that this really is a defect in the One very simple fix would be to execute the Compare: |
@bcmills - good idea. I'll look into that. |
I think you'll need read-write concurrency in a few other places too (particularly |
What version of Go are you using (
go version
)?Tested on:
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?linux/windows amd64
What did you do?
Run the following unit test:
$ go test -timeout 30s sshproxy -run TestHandshakeOverPipe
What did you expect to see?
Test pass (test passes when modified to use a real TCP connection)
What did you see instead?
Tests hang with both client and sever writing to write to the
net.Conn
duringssh.exchangeVersions
called fromclientHandshake
andserverHandshake
respectively.The text was updated successfully, but these errors were encountered: