Expand description
SSH terminals (P2 of SPEC_REMOTE_TERMINALS_AND_DURABLE_SESSIONS_2026_10_02.md).
A pane on an SSH connection runs the system ssh in its PTY (spec §3.1):
the user’s own ~/.ssh/config, keys, agent and known hosts apply, and
ssh asks for a password, a passphrase or a new host key in the terminal
itself, where the user answers it. The askpass bridge (§5.3), which an
agent’s non-interactive use needs, comes later.
Enums§
- Control
- What to ask a shared connection (
ssh -O).
Constants§
- EXIT_
CONNECTION_ FAILED sshexits 255 when it could not connect, could not authenticate, or the connection dropped; any other code is the remote command’s own.- NAME_
HASH_ 🔒HEX - Hex characters of the connection name’s hash in a socket’s name.
- SOCKET_
NAME_ 🔒MAX - The longest socket name ssh binds in a control dir: the name’s hash,
-, the 40-hex%C, and while binding.plus 16 random characters.
Functions§
- binary
- The
sshto run: the first onPATH, then (Windows) the OpenSSH client Windows installs, which an inheritedPATHcan lack. - binary_
for_ user binaryfor the user’s own interactive ssh pane, whose prompts are the user’s to answer in it: a native client is preferred whatever its version (Windows 10’s inbox OpenSSH is 8.1), still for its name resolution.- connection_
lost - Whether
sshending withcodemeans it had no connection, or lost it, rather than that the remote shell ended (exitincluded). A session on a shared connection that was closed or died ends this way too. - control
- The
ssharguments askingdest’s shared connection indirtoop: the same socket a pane’slaunchshares. - control_
dir - Where
ControlMastersockets go (macOS and Linux; Windows’ OpenSSH has no connection sharing): a private, owner-only directory, since anyone who can open a socket there can use the connection.None(no sharing; ssh still connects) if it can’t be made so, or a socket in it would be too long. - control_
dir_ 🔒in control_dirunderbase:base/ssh-<8 hex of config_home>, each level owner-only. A test can pass its ownbase.- control_
path_ 🔒option ControlPath=fordest’s shared connection indir:<name hash>-%C. ssh’s%Chashes the user, host and port ssh resolves, not the name it was given, so two aliases for one account (one with a key, one password-only) shared whichever connection logged in first, and the password-only one got in without asking (#4513). The connection’s own name keeps them apart;%Cstays so an alias pointed elsewhere gets a new connection.- forces_
askpass 🔒 - Whether
sshis OpenSSH 8.4 or newer, which honoursSSH_ASKPASS_REQUIRE=force; asked once per binary (ssh -V). - is_
posix_ 🔒layer_ build - An
ssh.exebuilt for MSYS2 or Cygwin: its runtime DLL sits beside it. Never true off Windows. - launch
- The
ssharguments for a pane.control_dir, on macOS and Linux, is where connection-sharing sockets live (ControlMaster), so a second pane on the same connection reuses the first one’s and asks for nothing. - launch_
exec - The
ssharguments for one command run without a terminal (an agent’sShell):launch’s, with-Tin place of-tt, since its output is read, not a session shown. - lost_
message - What the connection’s status says when a pane’s
sshlost it. - lost_
note - The line a plain SSH pane shows, under ssh’s own reason, when it has no connection: the pane stays, and Enter starts ssh again.
- missing_
binary_ message - What to say when there is no
ssh, with how to get it on this platform. - on_path 🔒
- openssh_
version 🔒 (major, minor)fromssh -V’s “OpenSSH_9.5p2, …” or “OpenSSH_for_Windows_8.1p1, …”.- pane_
lost_ connection - Whether a pane’s
ssh, ended withcode, lost its connection (or never had one).stopped_by_srv: srv ended it itself (the pane closed, or restarted), and ssh then exits 255 too (closing its pty does, and a session on a shared connection does on SIGTERM), which is no lost connection. - pick 🔒
binary’s order: the firstpreferredssh onPATH, then Windows’ own client if preferred, else the first onPATH, else Windows’ client.- private_
dir 🔒 - Make
dir(mode0700), or accept it if it already exists as a real directory owned by this user that no one else can enter./tmpis shared: someone else could have made the directory, or a symlink in its place. - push_
destination 🔒 - The port, if any, then
--and the destination:--ends ssh’s options, so the destination can never be read as one (conn.rs also refuses a leading-). - quote
- One word for a POSIX shell: single-quoted, with
'written as'\''. - quote_
path quotefor a remote path, leaving a leading~or~/unquoted so the remote shell expands it to the remote home (OSC 7 and users write it).- remote_
command - The command line
sshhands to the remote user’s login shell: the pane’s command, run incwdwhen one is set, or for a plain pane with a cwd, the login shell started there.Nonefor a plain pane with no cwd: ssh then starts the login shell itself. - set_
pane_ env - Name the pane in
launch’sSetEnvtoo (AGENTMUX_BLOCKID), so a host that accepts it (AcceptEnv AGENTMUX_*) lets the pane’s stats badge find its shell there (PaneProcs). Dropped quietly by any other host, like the rest of thatSetEnv. A block id is AgentMux’s own UUID; anything with another character is left out rather than quoted. - shared_
control_ dir control_dirfor this srv’s channel: where everysshit runs to a host (panes, agents’ commands, the helper, files) shares one connection.Nonewhere ssh can’t share connections, and then there is nothing to ask-O.- socket_
fits 🔒 - Whether ssh can bind a socket in
dir: the longest path it binds isdir/<name hash>-<40-hex %C>.<16 random>(SOCKET_NAME_MAX), and it has to fit insun_pathwith its NUL. - windows_
client 🔒 - Windows’ own OpenSSH client, if installed;
Noneelsewhere.