Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
Does this issue reproduce with the latest release?
I'm not able to verify this.
What operating system and processor architecture are you using (go env)?
What did you do?
In kubernetes e2e we are using ssh to fetch logs from kubernetes nodes.
In kubernetes/kubernetes#66609 we see that it quite frequently hangs for ~90 minutes in client.NewSession call (the stacktrace is there).
golang.org/x/crypto/ssh has some known issues that block clients
indefinitely when SSH server dies.
To workaround the problem, this commit creates TCP connection
to the server by itself then passes it to ssh.NewClientConn to
control the underlying TCP connection directly.
It adds deadlines against the TCP connection before any SSH
activity. It also enables TCP keepalive with short period.
What is the problem here? Your stack trace suggests it's waiting for the remote end to acknowledge the SSH session. If you want timeouts, you should implement them separately.
The problem is that there is no way (AFAIK) to prevent openChannel from blocking for hours in case the remote end never acks the SSH session.
I would like to see some timeout mechanism there. Could you hint how can I implement timeout there?
Arguably, the SSH package should support contexts to do this neatly, but I think it might be an invasive change, API wise.