sshkeepalive

package
v1.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package sshkeepalive runs an OpenSSH-style keepalive heartbeat over an ssh.Client (or any compatible Pinger), so long-lived SSH sessions don't get reaped by NAT/firewall idle timeouts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Start

func Start(p Pinger, interval time.Duration) (stop func())

Start launches a goroutine that sends an OpenSSH "keepalive@openssh.com" global request on p every interval. It returns a stop function the caller MUST invoke when shutting down. stop is idempotent.

An interval <= 0 disables the heartbeat: no goroutine is started and the returned stop is a no-op. This lets callers honor a "keepalive off" setting without special-casing it.

If SendRequest returns an error, the goroutine exits silently. Start does NOT close the underlying connection — the read loop on the client will detect EOF and surface it through the existing close path.

Types

type Pinger

type Pinger interface {
	SendRequest(name string, wantReply bool, payload []byte) (bool, []byte, error)
}

Pinger is the subset of *ssh.Client used to send keepalive global requests. Defining it as an interface keeps this package decoupled from net/ssh and makes it trivial to test with a fake.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL