scosh / engineering note

How scosh keeps
your shell running

A remote shell should survive a network change without adding a multiplexer.

scosh keeps one PTY on the server, uses OpenSSH for identity, and reconnects the running client to that same terminal state when the network changes. Your terminal remains the UI: its scrollback, search, selection, copy, mouse input, and terminal applications stay where they already work.

The problem with a normal SSH session

An SSH session normally owns the connection and the PTY together. If the connection disappears, the channel closes. Depending on what is running, the shell may exit, the process may receive a hangup, or the output you did not see is simply gone from the client.

tmux and screen solve this by moving the process into a multiplexer that survives outside SSH. That is the right answer when you need panes, windows, shared access, or public session ownership. It is extra machinery when all you wanted was for one remote shell to survive a network change.

One shell, two planes

scosh separates identity from transport. Each part has one job.

  1. OpenSSH authenticates the user. Host keys, agents, aliases, and the existing SSH configuration remain in charge. The bootstrap exchange is deliberately bounded.
  2. A separate data plane carries the session. The default path uses QUIC on one configured UDP port. When UDP is unavailable, --tcp carries the same session protocol over SSH stdio.
  3. The server worker owns the PTY. The PTY process and the authoritative terminal state stay on the server. The client is a view and an input path, not the owner of the shell.
  4. The client applies state. It starts from a complete snapshot, then applies contiguous updates. If it detects a gap or a cold reconnect, it asks for a new snapshot instead of guessing.
scosh transport and server architecture The terminal uses OpenSSH to authenticate and bootstrap, then uses QUIC or an SSH stream to reach one server-side PTY and its authoritative terminal state. A reconnect returns to that same PTY. CLIENT your terminal native scrollback selection + copy mouse + keyboard terminal applications IDENTITY OpenSSH bootstrap host trust · user auth · one-time token TRANSPORT QUIC or SSH stream updates · input · snapshots SERVER / scoshd one PTY the running shell terminal state screen · modes · revisions auth data network changes → fresh snapshot, same PTY No public session dashboard: the client process keeps reattach authority.
One server-side PTY, two transport paths. OpenSSH authenticates; QUIC or SSH carries the session.

What happens when the network changes

The important property is that a short disconnect does not create a replacement shell. The original client keeps its reattach authority in memory. When the transport is available again, it authenticates a new data connection for the same server-side session and requests the state it needs.

The recovery path is intentionally conservative:

There is no public session dashboard. Reattach authority stays in the client process that created the session; there are no public session IDs, list, or takeover APIs. That keeps the control surface small and avoids ownership races. Use tmux or screen when a shell needs to be shared.

Why the terminal stays native

scosh does not put a custom history screen in front of your terminal. The host terminal still receives terminal output and input, so the familiar interactions remain native:

The server maintains structured terminal state so it can recover accurately. That state is implementation machinery, not a second user interface.

Why QUIC is not the whole reliability story

QUIC provides an encrypted, connection-oriented transport with reliable streams and datagrams. It does not know whether a terminal effect has been applied, whether a snapshot has been rendered, or whether a client has crossed a screen-mode transition.

scosh therefore keeps a small application-level state protocol:

This is not a second byte transport. It is the minimum semantic layer needed to keep a terminal state machine from silently drifting.

Security boundaries

OpenSSH remains the identity and host-trust boundary. The data plane is separately authenticated using the bootstrap-delivered server identity and a short-lived, one-time session token. The token is not a public session handle and is not intended to be copied into another client.

There is no hosted relay, account service, or cloud session registry in the current design. The server is a Linux service that owns the PTY; the client process owns the authority to recover its session.

What scosh is not

Not a multiplexerUse tmux for panes, windows, shared sessions, or team ownership.
Not a VPNIt carries one authenticated shell session, not arbitrary network traffic.
Not an SSH replacementSSH still authenticates the user and bootstraps the connection.
Not a hosted serviceYour server, PTY, and terminal state stay under your control.

Try it

# normal path
scosh dev@example.com

# keep the session on SSH when UDP is unavailable
scosh --tcp dev@example.com

scosh is currently v0.1.0. The production server targets Linux x86_64 with the native terminal engine; clients target macOS and Linux. See the installation page and deployment guide for the current boundary.