A desktop SSH client can show an interactive shell and a remote file browser for the same host. Their lifetimes are different: a user may close Files, cancel an upload, or switch hosts while keeping a shell open.
That creates a useful design question: which component owns the connection that a cancellation is allowed to close?
I'm the maintainer of Netrix, a desktop terminal client. This article examines the SFTP connection lifecycle in its public 0.3.0-beta.8 source snapshot. The implementation is in Rust, using Tokio and russh.
SSH channels and connection ownership
SSH supports multiple channels within one encrypted connection. A shell and an SFTP subsystem can use different channels on a shared connection; the protocol does not require a separate connection for every feature. RFC 4254 describes the channel mechanism .
Sharing can avoid additional connection setup and authentication. It also means the application needs a clear owner for the shared transport.…