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: connection.session.Close() returns a EOF as error instead of nil #38115
Comments
Hi there, This seems like a question rather than a report about a bug in the implementation (at least yet). Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only. For asking questions, see:
Please ask the question on one of the above forums. (Quoted from https://golang.org/wiki/Questions) |
Hi, However, this was recognized as a bug. |
Sounds good. Re-opening. |
it looks like this happens when running against OpenSSH. Can you provide a repro of Go SSH running against itself? I'm asking because there might be some configuration that on SSH server that tears down the connection if a Session is finished. |
Is there an example of the Go SSH server I can try to run or that might help debug for you? I never ran a SSH server, usually test against another host that I can ssh to (which I guess normally run OpenSSH). |
I am having the same problem go version go1.16.6 linux/amd64 |
I notice a similar problem (nonsensical io.EOF returned by Close) from the Close method of the *ssh.channel data type too. The likely cause is channel.Close -> channel.sendMessage-> channel.writePacket, which returns EOF if a close has already occurred, suggesting an application bug, but nonetheless, EOF is the wrong error in that situation. [Update: on further investigation, the sentClose field was true because the ssh mux loop received a close packet from the peer, and handled it by sending a close packet in response, then calling ch.close, which sets sentClose. The application only called Close once on the result of OpenChannel.] |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, I believe I am using the latest stable release.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
My program connects to a ssh server (just my laptop in this case) and issues an ssh command closes the SSH session, and connection:
What did you expect to see?
At session.close(), I was expecting to see 'nil' as the output instead of any error.
What did you see instead?
I'm getting an EOF error in session.Close(). Looking at other raised issues in this forum (#16194) it sounds reasonable to get the EOF at end of Run(). However, for Close() this seems odd to have it return as an error instead the return as nil.
It could be that Im not handling something properly in terms managing the buffer or executing command or closing it. But the code I pasted above is from examples online and it looks like the working model.
EOF at close is something I can handle but to be very clear and precise I believe Close() should return nil. And EOF doesn't seem like an error either.
The text was updated successfully, but these errors were encountered: