Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
x/crypto/ssh: client.NewSession can hang indefinitely #26643
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
golang.org/x/crypto/ssh has some known issues that block clients indefinitely when SSH server dies. Ref: golang/go#26643 golang/go#21420 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.
Arguably, the SSH package should support contexts to do this neatly, but I think it might be an invasive change, API wise.
Thanks for the response!
I would like to see some timeout mechanism there. Could you hint how can I implement timeout there?