Add --idle-timeout to auto-close inactive SSH sessions#775
Draft
Copilot wants to merge 3 commits into
Draft
Conversation
Agent-Logs-Url: https://github.com/tg123/sshpiper/sessions/ecb21131-2443-4af6-97fd-3f9e112766f0 Co-authored-by: tg123 <170430+tg123@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add option to auto close SSH session after inactivity
Add May 2, 2026
--idle-timeout to auto-close inactive SSH sessions
Owner
|
@copilot is the impl too heavy? |
Agent-Logs-Url: https://github.com/tg123/sshpiper/sessions/736e8f5f-87e6-4438-b6e1-47534be215ce Co-authored-by: tg123 <170430+tg123@users.noreply.github.com>
Contributor
Author
Good call — replaced the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Users have no way to force-close SSH sessions through
sshpiperdafter a period of inactivity. This adds an opt-in idle timeout on the daemon.Changes
--idle-timeoutflag onsshpiperd(envSSHPIPERD_IDLE_TIMEOUT, default0= disabled). Accepts any Go duration, e.g.5m.newIdleTimeoutHook(cmd/sshpiperd/idletimeout.go): a tiny ~15-line helper that returns aPipePacketHookwhich callstimer.Reset(timeout)on channel-data packets. The daemon creates a singletime.AfterFunc(d.idleTimeout, ...)that closes thePiperConnon idle, installs the hook on both up/down chains, anddefer timer.Stop()s it on teardown. No goroutine, no atomic state, no stop channel — just stdlibtime.Timer.SSH_MSG_CHANNEL_DATA(94) andSSH_MSG_CHANNEL_EXTENDED_DATA(95) reset the timer. Keepalives, window adjustments, and other control packets are intentionally ignored so client/server SSH keepalives don't defeat the timeout (cf. OpenSSHClientAliveInterval). This also addresses the maintainer's question on the issue about what "inactive" means.PipePacketHookTransform, packet returned unchanged).idletimeout_test.gocover: disabled-on-zero / nil timer, only channel-data resets the timer, and ongoing channel-data keeps the timer alive.cmd/sshpiperd/snap/README.md) updated.Example
A pipe with no channel-data traffic in either direction for 5 minutes is closed: