Skip to content
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: add support for alive interval #19338

Open
dsnet opened this Issue Mar 1, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@dsnet
Copy link
Member

dsnet commented Mar 1, 2017

When the underlying TCP connection for a long-standing SSH connection abruptly dies, operations on an ssh.Client can hang forever. This is because the client remains stuck in an io.ReadFull call with no preceding or concurrent calls to net.Conn.SetDeadline. Without any deadline set, there is no guarantee that Read will ever return.

Even though the user has access the underlying net.Conn and can set the deadline themselves, they have no way of determining if the underlying connection is actually dead or just idle. Thus, the ssh package should support this functionality that allows sending of empty messages to intentionally invoke a response from the remote endpoint, in order to determine if it is still alive.

This is a feature request for the equivalent options for OpenSSH:

  • AliveInterval time.Duration: Sets a timeout interval after which, if no data has been received, sends an alive message through the encrypted channel to invoke a response from the remote end. The default is 0, indicating that such messages will not be sent.
  • AliveCountMax int: Sets the number of alive messages which may be sent without receiving a response from the remote end. If this threshold is reached while alive messages are being sent, the SSH session will be terminated.

If this is reasonable, I can implement this.

@dsnet dsnet added this to the Unreleased milestone Mar 1, 2017

@dsnet

This comment has been minimized.

Copy link
Member Author

dsnet commented Mar 1, 2017

\cc @hanwen

@hanwen

This comment has been minimized.

Copy link
Contributor

hanwen commented Mar 1, 2017

you can trivially do this yourself by sending a message in a loop on a timer.

@nhooyr

This comment has been minimized.

Copy link
Contributor

nhooyr commented Aug 16, 2017

@hanwen see #21478 for why that's not efficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.