Skip to content

feat: inject SSH keepalive options to prevent idle drops - #2747

Merged
oferchen merged 3 commits into
masterfrom
feat/ssh-keepalive
Mar 17, 2026
Merged

oferchen merged 3 commits into
masterfrom
feat/ssh-keepalive

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Injects -o ServerAliveInterval=20 and -o ServerAliveCountMax=3 into SSH command lines by default, preventing firewalls and NAT devices from dropping idle connections during long transfers
  • Skips injection when the user already specifies ServerAliveInterval or ServerAliveCountMax via -e / push_option / configure_remote_shell (case-insensitive detection)
  • Skips injection for non-SSH programs (e.g., plink, rsh)
  • Provides set_keepalive(false) to explicitly disable injection

Test plan

  • Verify keepalive options are injected by default
  • Verify keepalive options appear before user-specified options
  • Verify keepalive is omitted when explicitly disabled
  • Verify keepalive is omitted for non-SSH programs
  • Verify keepalive is omitted when user specifies ServerAliveInterval
  • Verify keepalive is omitted when user specifies ServerAliveCountMax
  • Verify keepalive is omitted when remote shell spec contains keepalive options
  • Verify case-insensitive detection of user-specified keepalive options
  • Verify existing tests updated for new default behavior

@github-actions github-actions Bot added the enhancement New feature or request label Mar 16, 2026
Add ServerAliveInterval=20 and ServerAliveCountMax=3 to the SSH command
line by default, preventing firewalls and NAT devices from dropping idle
connections during long transfers. The injection is skipped when the user
already specifies keepalive options (case-insensitive detection), when
the program is not ssh, or when explicitly disabled via set_keepalive().
The execute_with_bandwidth_limit_records_sleep test failed on Windows
nightly with a diff of 501.954ms against a 500ms tolerance. Increase
tolerance to 750ms to account for timer resolution and nightly variance.
@oferchen
oferchen force-pushed the feat/ssh-keepalive branch from de40260 to 33e1105 Compare March 17, 2026 01:19
@oferchen
oferchen merged commit 59041a4 into master Mar 17, 2026
31 checks passed
@oferchen
oferchen deleted the feat/ssh-keepalive branch March 17, 2026 04:49
oferchen added a commit that referenced this pull request May 1, 2026
* feat: inject SSH keepalive options to prevent idle connection drops

Add ServerAliveInterval=20 and ServerAliveCountMax=3 to the SSH command
line by default, preventing firewalls and NAT devices from dropping idle
connections during long transfers. The injection is skipped when the user
already specifies keepalive options (case-insensitive detection), when
the program is not ssh, or when explicitly disabled via set_keepalive().

* formatting

* fix: increase bandwidth test tolerance for Windows nightly CI

The execute_with_bandwidth_limit_records_sleep test failed on Windows
nightly with a diff of 501.954ms against a 500ms tolerance. Increase
tolerance to 750ms to account for timer resolution and nightly variance.
oferchen added a commit that referenced this pull request May 5, 2026
* feat: inject SSH keepalive options to prevent idle connection drops

Add ServerAliveInterval=20 and ServerAliveCountMax=3 to the SSH command
line by default, preventing firewalls and NAT devices from dropping idle
connections during long transfers. The injection is skipped when the user
already specifies keepalive options (case-insensitive detection), when
the program is not ssh, or when explicitly disabled via set_keepalive().

* formatting

* fix: increase bandwidth test tolerance for Windows nightly CI

The execute_with_bandwidth_limit_records_sleep test failed on Windows
nightly with a diff of 501.954ms against a 500ms tolerance. Increase
tolerance to 750ms to account for timer resolution and nightly variance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant