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
SshSupervisorBuilder— fluent builder for the supervisor.SshSupervisor— the supervisor task; drive viarun().await.MonitorMode—-M 0(None) or-M <port>[:<echo>](Active).SupervisorEvent— emitted over the user’smpsc::Sender.AutosshError— public error type.
§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/
-fdaemonization. - 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.
- SshSupervisor
Builder - Fluent builder for
SshSupervisor.
Enums§
- Compatibility
Mode - Compatibility mode resolved from the
--strict/--no-strictflags,RUSTY_AUTOSSH_STRICTenv var, andargv[0]basename per AD-006. - Monitor
Mode - Monitor-port mode resolved from the
-Mflag orAUTOSSH_PORTenv var. - Signal
Kind - Signal-kind tag carried by
SupervisorEvent::SignalReceived. - Supervisor
Event - Events emitted by
SshSupervisor::runover the consumer’smpsc::Sender<SupervisorEvent>(set on the builder viaSshSupervisorBuilder::event_sender).