Skip to main content

Crate rusty_autossh

Crate rusty_autossh 

Source
Expand description

§rusty-autossh

A Rust port of Carson Harding’s autossh(1) SSH connection supervisor. Spawns ssh as a child process, optionally probes tunnel liveness via the -M <port> heartbeat (or -M 0 exit-only respawn), and respawns the ssh process when it dies or stops responding.

This crate ships both a CLI binary (rusty-autossh) and a Rust-native library API. With default-features = false the library API is available without pulling in any CLI-only dependencies (clap, clap_complete, anstyle, tracing-appender, daemonize, atomicwrites, windows-sys).

§Library entry points

§Feature gates

  • default = ["cli"] — full CLI binary + library API.
  • default-features = false — library only (tokio + thiserror + socket2).

§SemVer + thread-safety policy

AutosshError and SupervisorEvent are #[non_exhaustive] per AD-014, so additive variants in later releases are NOT breaking changes. SshSupervisor: Send, SshSupervisorBuilder: Send + Sync, all enums Send + Sync. See tests module for the static_assertions guards.

§Concurrency

SshSupervisor::run requires exclusive ownership of SIGCHLD in the host tokio runtime per FR-062 / AD-017. Library consumers running multiple supervisors must run each in its own dedicated tokio runtime.

§Quick-start example

use rusty_autossh::{MonitorMode, SshSupervisorBuilder};

let mut supervisor = SshSupervisorBuilder::new()
    .ssh_args(vec!["user@host".to_string()])
    .monitor_mode(MonitorMode::None)
    .build()?;

supervisor.run().await?;

Re-exports§

pub use error::AutosshError;

Modules§

cli
Default-mode CLI parsing via clap-derive.
clock
Poll clock configuration.
daemonizer
Background/-f daemonization.
error
Public error type for rusty-autossh.
logging
Log-file writer for the supervisor.
mode
Strict-mode activation precedence ladder.
monitor
Monitor-port heartbeat probe.
pidfile
Atomic pidfile writer with RAII cleanup.
signals
Cross-platform signal source.
spawner
SSH child-process spawner.
strict
Hand-rolled Strict-mode argv parser.
supervisor
Supervisor loop — the heart of the rusty-autossh port.

Structs§

SshSupervisor
SSH connection supervisor.
SshSupervisorBuilder
Fluent builder for SshSupervisor.

Enums§

CompatibilityMode
Compatibility mode resolved from the --strict / --no-strict flags, RUSTY_AUTOSSH_STRICT env var, and argv[0] basename per AD-006.
MonitorMode
Monitor-port mode resolved from the -M flag or AUTOSSH_PORT env var.
SignalKind
Signal-kind tag carried by SupervisorEvent::SignalReceived.
SupervisorEvent
Events emitted by SshSupervisor::run over the consumer’s mpsc::Sender<SupervisorEvent> (set on the builder via SshSupervisorBuilder::event_sender).