All 22 apps

CandySshLauncher

TUI directory of SSH endpoints

inspired by charmbracelet/wishlist ssh launcher yaml-config

CandySshLauncher code coverage

Launch candy-ssh-launcher, pick a host, and press Enter. The launcher replaces its own process with ssh connecting to that host, so the prompts, the keys and the exit code are all ssh's. It is a PHP port of the selection flow in charmbracelet/wishlist: your machines live in one YAML or JSON list, you type to narrow it, and Enter connects. The picker is a one-shot local widget, not a server-backed store.

Install

composer require sugarcraft/candy-ssh-launcher:@dev

Until the first candy-ssh-launcher/v* tag is cut, the package publishes only its dev branch, so a bare composer require finds nothing under Composer's default minimum-stability. The :@dev suffix names that branch explicitly. The binary lands at vendor/bin/candy-ssh-launcher, and tools/build-phar.php builds a single-file .phar.

Requires PHP 8.3 or newer with ext-pcntl (the launcher hands off with pcntl_exec), a Unix host (raw-mode terminals, pcntl and ~ expansion have no Windows story) and a UTF-8 terminal, because the picker draws ▸, ─ and ….

Quickstart

Endpoints form a flat top-level YAML list. This is examples/sample-wishlist.yml:

# Sample wishlist directory. Copy to ~/.config/wishlist.yml and edit.

- name: production
  host: prod.example.com
  port: 2222
  user: deploy
  # A leading ~ on an identity path is expanded by the launcher ($HOME,
  # passwd fallback). An absolute path is the portable spelling — it does
  # not depend on who expands it.
  identity_file: ~/.ssh/prod-deploy
  description: Live customer-facing app servers

- name: staging
  host: stage.example.com
  user: deploy
  description: Pre-prod mirror — safe to break

- name: dev
  host: dev.example.com
  user: dev

- name: jumpbox
  host: bastion.example.com
  options:
    - ServerAliveInterval=30
    - ServerAliveCountMax=3

Run the picker in a terminal. With no --config, the launcher looks for wishlist.yml in the current directory, then in ~/.config:

vendor/bin/candy-ssh-launcher --config examples/sample-wishlist.yml

Without a terminal, --list prints one row per endpoint (name, host:port, user or -), tab-separated, and exits 0:

production	prod.example.com:2222	deploy
staging	stage.example.com:22	deploy
dev	dev.example.com:22	dev
jumpbox	bastion.example.com:22	-

Concepts

The config file is trusted input, exactly like ~/.ssh/config. The launcher does not sandbox a wishlist. It turns each row into an argument list and gives that list to ssh, so the rows decide what runs. The security section below explains which rows deserve a second look.

An endpoint becomes an argv list. Endpoint::toSshArgv() emits ssh, then -p when the port is not 22, one - flag per letter in flags, one -i per identity file in order, -J for a jump host, one -o per option, then --, the destination and an optional remote command. A value that starts with a dash is refused by name before it reaches argv, so a config cannot smuggle a second option in through a host or identity field.

The picker is a one-shot widget. Picker::pick() draws one frame, reads keys until Enter or Esc, and returns one Endpoint or null. It needs a real terminal on both stdin and stdout, so a piped run is refused with exit 2. Pasted text is typed into the filter and never connects, even when the paste ends in a newline.

Dispatch replaces the process. Launcher::dispatch() calls pcntl_exec with the vetted binary, which performs no $PATH search. A successful call never returns, so signals and the exit status belong to ssh. A failed exec throws, and the CLI reports it as exit 3.

Tasks

Connect from the picker

Type to narrow the list (the match is fuzzy and scored by sugar-fuzzy), move with the arrow keys, and press Enter. The header shows the shown-of-total count while a filter is live, and a (no matches …) line appears when the filter removes every row.

Connect by name, without the picker

A bare positional argument names an endpoint. An exact, unique match dispatches straight away and never touches the terminal, so it works in scripts, because ssh gets the terminal and no picker is drawn. An ambiguous name opens the picker already filtered to the matches. An unknown name opens the full picker rather than failing on a typo.

vendor/bin/candy-ssh-launcher --config examples/sample-wishlist.yml staging

Import your OpenSSH config

--from-ssh-config reads endpoints from an OpenSSH config instead of a wishlist. Host patterns become endpoint names, and HostName (or the pattern, when no HostName is given) becomes the host. Without --config it reads ~/.ssh/config, which is auto-discovered and therefore passes the same ownership gate. The source file is named on stderr so an imported list is never mistaken for your wishlist.

vendor/bin/candy-ssh-launcher --from-ssh-config
vendor/bin/candy-ssh-launcher --from-ssh-config --config ~/lab/ssh_config

Jump through a bastion with keys and flags

Set proxyJump for -J, list identityFiles (each becomes its own -i, in order), add options for -o, and use flags for the letter-only switches such as t (-t) or N (-N).

- name: db-prod
  host: db.internal.example.com
  user: dba
  proxyJump: bastion.example.com
  identityFiles:
    - ~/.ssh/prod-deploy
    - ~/.ssh/prod-dba
  options:
    - ServerAliveInterval=30
  flags:
    - t
  remoteCommand: psql

Use a different transport for one host

A row may set command (the alias transport is accepted) to name a different binary for that endpoint, such as a mosh-style client. The binary passes the same exists-and-executable check as --ssh, and it is not searched on $PATH. Fields the custom transport cannot carry (identityFiles, proxyJump, options and remoteCommand) are dropped, and the launcher prints one stderr line naming each dropped field before it runs.

Script the list

--list is the machine-readable view and never launches anything, so it stays safe in a pipe. Each row is name, host:port and user (or -). Tabs and line breaks inside a value are folded to spaces so one endpoint is always one row, and a duplicated name gets a #n suffix with its 1-based config index. A config with zero endpoints prints nothing and exits 0 under --list.

vendor/bin/candy-ssh-launcher --list | awk -F'\t' '$3 == "deploy" { print $1 }'

API

Every class lives under SugarCraft\SshLauncher\. Endpoint and Config are the data path, and Picker and Launcher are the two seams an embedding program would call.

API surface
ClassMethodDescription
Endpoint__construct(name, host, port = 22, user, identityFiles, description, proxyJump, options, flags, remoteCommand, command)Readonly value object. An empty name or host, or a port outside 1 to 65535, throws
EndpointparsePort(string $host, mixed $raw): intAccepts integers and unsigned decimal strings only. Booleans, floats and junk are refused by name
EndpointtoSshArgv(string $binary = 'ssh'): list<string>The full argv for ssh, ready for pcntl_exec
EndpointtoTransportArgv(string $binary): list<string>The argv for a custom command: port, flags and destination only
EndpointtransportIncompatibles(), unsafeOptions(), displayLine()The fields a custom transport drops, the options that weaken trust, and the picker row text
EndpointwithName(), withHost(), withPort(), withUser(), withIdentityFiles(), withDescription(), withProxyJump(), withOptions(), withFlags(), withRemoteCommand(), withCommand()Fluent setters. Each returns a new endpoint and leaves the receiver unchanged
Configload(string $path): list<Endpoint>Loads a YAML or JSON wishlist, detecting the format from the extension
Configparse(string $raw, string $hintPath = 'wishlist'): list<Endpoint>Parses wishlist text. The hint path picks the format, and JSON is assumed when the text opens with [ or {
ConfigimportFromSshConfig(string $path): list<Endpoint>Imports endpoints from an OpenSSH config
ConfigsetWarningStream($stream)Routes load warnings to a stream. The default is stderr, and tests use it to capture warnings
Picker__construct($in = null, $out = null), pick(array $endpoints): ?EndpointRuns the picker on the given streams. Returns null on cancel, on an empty list, or when the terminal is too narrow
Launcher__construct(?callable $executor = null), dispatch(Endpoint $e, string $sshBinary = Launcher::DEFAULT_SSH): voidThe executor seam receives the binary and argv. The default executor replaces the process and throws when the exec fails
LauncherfirstExecutableSsh(array $candidates): ?stringThe first existing executable among the known ssh locations, or null
IdentityPathexpand(string $path): stringExpands a leading ~ against $HOME, with a passwd fallback

Only methods declared in candy-ssh-launcher/src, or inherited from a parent declared there, are listed. A type that extends a class outside that tree, such as \RuntimeException, does not show the methods of that class.

SugarCraft\SshLauncher

Config final class

Loads a wishlist directory from disk.

MethodSummary
static setWarningStream($stream): voidTest seam: route load warnings to $stream (null restores STDERR).
static load(string $path): array
static parse(string $raw, string $hintPath = 'wishlist'): array
static importFromSshConfig(string $path): arrayImport endpoints from an OpenSSH config file (~/.ssh/config).

Endpoint final class

One row in a wishlist directory — a host the user can pick to ssh into. Held as an immutable value object; build via new Endpoint(...) or via Config::load().

Not listed: the methods of SugarCraft\Core\Concerns\Mutable, a trait declared outside src/.

MethodSummary
__construct(public readonly string $name, public readonly string $host, public readonly int $port = 22, public readonly ?string $user = null, public readonly array $identityFiles = [], public readonly ?string $description = null, public readonly ?string $proxyJump = null, public readonly array $options = [], public readonly array $flags = [], public readonly ?string $remoteCommand = null, public readonly ?string $command = null)
static parsePort(string $host, mixed $raw): intParse+validate a config-supplied port before it reaches the ctor. Accepts ints and unsigned decimal strings only — booleans, floats and anything ((int)) would silently mangle ("notanumber" → 0) are refused by name, not coerced.
toSshArgv(string $binary = 'ssh'): arrayBuild the argv list for ssh(1). The first element is the binary name (ssh); the rest is options, the destination and — per the ssh(1) synopsis ssh [options] destination [command] — an optional remote command riding after the destination. Suitable for pcntl_exec($argv[0], array_slice($argv, 1)).
toTransportArgv(string $binary): arrayBuild the argv list for a custom transport (-027): binary, the -p port leg when it is not 22, the raw flag lane, then the destination — nothing else. The ssh-only machinery (-i/-J/-o legs and the remote-command positional) is left out because mosh-class transports reject it; transportIncompatibles() names what was set but dropped so the launcher can warn instead of silently trimming. The flags lane rides verbatim by design — the user picked a custom binary precisely to speak its dialect.
transportIncompatibles(): arrayThe fixed field names whose values would be silently lost by toTransportArgv() — computed from what is actually set, so a plain mosh row (command: /usr/bin/mosh and nothing else) carries no warning debt.
unsafeOptions(): arrayThe host-key-trust-destruction family (candy-ssh-launcher-029).
displayLine(): stringThe picker row for this endpoint.
withName(string $name): self
withHost(string $host): self
withPort(int $port): self
withUser(?string $user): self
withIdentityFiles(array $identityFiles): self
withDescription(?string $description): self
withProxyJump(?string $proxyJump): self
withOptions(array $options): self
withFlags(array $flags): self
withRemoteCommand(?string $remoteCommand): self
withCommand(?string $command): self

IdentityPath final class

Tilde expansion for identity-file paths, ONE implementation shared by both ingest paths (F-4, 2026-11-06).

MethodSummary
static expand(string $path): stringExpand a leading ~ in an identity-file path; everything else is returned verbatim.

Lang final class

Per-library translation facade for candy-ssh-launcher.

Launcher final class

Replaces the current PHP process with ssh(1) connecting to the chosen Endpoint. Uses pcntl_exec() so file descriptors, environment, controlling tty, and exit status all flow through unchanged — the user sees a normal ssh session, including host-key prompts, agent forwarding, and the standard MOTD.

MethodSummary
static firstExecutableSsh(array $candidates = self::SSH_CANDIDATES): ?stringFirst candidate that is an existing executable file, or null when none is — the caller then falls back to DEFAULT_SSH and the honest exit-1 refusal names the default.
setWarningStream($stream): void
__construct(?callable $executor = null)
dispatch(Endpoint $e, string $sshBinary = self::DEFAULT_SSH): voidDispatch into the chosen endpoint. On success, the PHP process is replaced and this method does not return; on failure the executor throws.

Picker class

Tiny terminal picker — renders marker-prefixed display lines (selectedMarker() over displayLine()) of Endpoints. The user moves with ↑/↓, Home/End and PgUp/PgDn (j/k are query letters on every row — the invert model, -060), narrows with type-to-search, and picks with Enter. Returns the selected Endpoint, or null on Esc or the cancel byte (0x03 — what a closed stdin maps to as well). On a real terminal Ctrl-C raises SIGINT, which the picker traps to restore the terminal before exiting 130.

MethodSummary
__construct($in = null, $out = null)
pick(array $endpoints): ?Endpoint

SshConfigParser final class

Parses an OpenSSH config file (~/.ssh/config) into a list of Endpoints.

MethodSummary
parse(string $raw): array

SugarCraft\SshLauncher\Support

CommentStrip final class

The quote-aware trailing-comment strip shared by both config readers.

MethodSummary
static strip(string $line): stringStrip a trailing '#' comment from a config line — quote-aware (F-18).

Version final class

Version surface for the phar build (the installed-version probe shape).

MethodSummary
static resolve(string $archive): stringResolve the version for the current run.
static fromPharMetadata(string $archivePath): ?stringRead and normalize the version stamp inside an archive, or null when the path is empty, is not a file, is not a readable phar, or its stamp does not parse as a comparable release. Every failure mode falls back to null rather than throwing — a corrupt archive must not crash --version.

Keys

The picker reads these keys in its raw-mode loop. Letters always type into the filter, so j and k do not move the selection.

Picker keys
KeyEffect
↑ / ↓Move the selection through the matches (CSI and SS3 forms both work)
Home / EndJump to the first or last match
PgUp / PgDnMove by one visible page
Any printable characterAppend to the filter (fuzzy match over the display line)
Backspace or Ctrl+HDelete the last character of the filter
Ctrl+WDelete the last word of the filter
Ctrl+UClear the whole filter
EnterConnect to the highlighted endpoint (no match, no action)
Esc or Ctrl+CCancel and exit 130

Configuration

The launcher has a small command line, a handful of environment variables and one per-endpoint schema.

Command-line options
OptionEffect
--config <path> (or --config=<path>)Read this wishlist (or, with --from-ssh-config, this OpenSSH config). Naming a path skips the ownership and mode gate, because naming a path is consent.
--ssh <path>The ssh binary. Must be an existing executable path. A bare name such as ssh is refused, because nothing searches $PATH.
--from-ssh-configImport endpoints from an OpenSSH config. See the task above.
--listPrint the endpoints as tab-separated rows and exit 0. No terminal and no ssh are needed.
[endpoint]Positional name. An exact, unique match dispatches directly; an ambiguous or unknown name falls back to the picker.
-h, --helpPrint usage, the keys and the exit codes, then exit 0.
-v, --versionPrint the version, then exit 0. No config is read.
--End option parsing. Anything after it is ignored, so name the endpoint before it.

Where the wishlist comes from

Without --config, the first file that exists wins at each tier, and the tiers are searched in this order:

  1. The current directory: wishlist.yml, then wishlist.yaml, then wishlist.json. A notice on stderr names the project-local file.
  2. The user directory: the same three names under $XDG_CONFIG_HOME when it is set and non-empty, otherwise under ~/.config.

Auto-discovered files face a trust gate. A file owned by another user (root excepted) or writable by its group or by others is refused by name. Keep the file owned by you and at mode 0600 or 0644.

Ssh binary resolution

--ssh wins. Otherwise SSH_LAUNCHER_SSH is used when set. Otherwise the first existing executable of /usr/bin/ssh, /run/current-system/sw/bin/ssh and /opt/homebrew/bin/ssh is used, and /usr/bin/ssh is the final fallback. The gate then checks that the chosen path is an executable file, and it refuses honestly when it is not.

Environment

Environment variables
VariableEffect
SSH_LAUNCHER_SSHThe ssh binary when --ssh is absent. Use an absolute path.
XDG_CONFIG_HOMEBase directory for the user wishlist when set and non-empty.
HOMELocates ~/.config, ~/.ssh/config and the expansion of ~ in identity paths.
LC_ALL, LC_MESSAGES, LANGMessage locale, read in that order. The messages ship in 16 catalogs, English included.
NO_COLOR, CLICOLOR=0Remove all color escapes. The layout glyphs stay.
TERM=dumbSingle-pass frames with no cursor addressing, no alternate screen and no bracketed paste.
ESCDELAYMilliseconds to wait after an Esc for the rest of an escape sequence, 1 to 4 digits. The default is 150.

Endpoint fields

Endpoint fields
Field (aliases)TypeDefaultEffect
namestringrequiredIdentifier used for dispatch and shown in the picker. An empty name is refused. Duplicates load with a warning.
hoststringrequiredDestination host. An empty host is refused.
portinteger 1 to 6553522Passed as -p when it is not 22.
userstringnoneMakes the destination user@host.
descriptionstringnoneDim text after the row in the picker.
identityFiles (identity_files, identity_file, identityFile)string or listnoneOne -i per entry, in order. A leading ~ is expanded against $HOME.
proxyJump (proxy_jump)stringnonePassed as -J.
optionslist of stringsnoneEach entry becomes -o with the value verbatim, for example ServerAliveInterval=30.
flagslist of lettersnoneEach letter becomes - plus the letter, for example t gives -t.
remoteCommand (remote_command)stringnonePassed after the destination, where ssh expects a remote command.
command (transport)stringnoneReplaces the ssh binary for this endpoint. See the task above.

A key outside this list, and outside the aliases, is named on stderr and ignored, so a typo never changes the connection silently. The loader refuses files larger than 4 MiB, refuses a list field with more than 1000 items, strips a leading UTF-8 byte-order mark, and refuses UTF-16 by name.

Security

Whatever a wishlist declares, the launcher passes to ssh. Most options are safe, but a few weaken the trust that ssh gives a connection, and ProxyCommand and LocalCommand run commands at connect time. Before it execs, the launcher prints one stderr line for each option that degrades host-key trust or logging, naming the option and what it costs:

  • StrictHostKeyChecking set to no, never or accept-new
  • LogLevel set to quiet, error or fatal
  • UserKnownHostsFile, GlobalKnownHostsFile, IdentityAgent and CertificateFile, whatever their value

Keep wishlists and ~/.ssh/config owned by you, and do not accept endpoint files from other people. The fleet-wide rules are in the trust boundary document.

Theme and styling

The picker has no theme option. Its palette is fixed: a bold cyan ▸ marker on the selected row, a cyan filter line, and dim gray descriptions. NO_COLOR and CLICOLOR=0 remove every color escape, and the marker and the layout stay, so the selection is still visible without color. --list prints plain text in every case.

Examples

examples/endpoint-argv.php loads the sample wishlist and prints the ssh argv each endpoint would produce. It executes nothing and exits 0.

php examples/endpoint-argv.php
production
  ssh -p 2222 -i /home/you/.ssh/prod-deploy -- deploy@prod.example.com
staging
  ssh -- deploy@stage.example.com
dev
  ssh -- dev@dev.example.com
jumpbox
  ssh -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -- bastion.example.com

The -i path is the first endpoint's identity file expanded against your $HOME, so that line differs between machines.

examples/unsafe-options.php parses an inline wishlist and lists the options that the launcher would flag before connecting. It exits 0.

php examples/unsafe-options.php
lab: StrictHostKeyChecking=no
legacy: UserKnownHostsFile=/dev/null, LogLevel=quiet

examples/sample-wishlist.yml is the config used in the quickstart.

Testing

cd candy-ssh-launcher && composer install && vendor/bin/phpunit

The suite covers the config loader (ConfigTest, ConfigHardeningTest, ConfigEncodingTest), the argv builder (EndpointArgvSafetyTest, EndpointIdentityFilesTest), the OpenSSH importer (SshConfigParserTest), the picker (PickerTest, PickerInputIntegrityTest), the exec handoff through the executor seam (LauncherTest, ExecHandoffTest), the CLI (BinCliTest), the translation catalogs (LocaleParityTest) and a pseudo-terminal signal test (PtySignalIntegrationTest).

Troubleshooting and FAQ

The picker needs an interactive terminal

The launcher exits 2 and prints the picker needs an interactive terminal when stdin or stdout is not a TTY. Use --list to read the endpoints, or name an endpoint, which dispatches without a terminal when the name is unique.

A config is refused as owned by another user or writable

An auto-discovered file that another user owns, or that its group or the world can write, exits 1 and is named in the message. Run chmod 600 on it, or pass the file explicitly with --config, which skips the gate because naming a path is consent.

It says the file looks like an OpenSSH config

A file with a line that begins with Host is ssh config syntax, not a wishlist. The launcher refuses it and points at --from-ssh-config. A top-level mapping keyed by endpoint name, the shape charmbracelet/wishlist uses, is also refused, because the schema is a flat list. The README names the failure.

The ssh binary is not found or not executable

Pass --ssh /absolute/path/to/ssh, or set SSH_LAUNCHER_SSH. A bare name such as ssh is never resolved through $PATH, because pcntl_exec receives exactly the path the gate vetted.

The picker exits 130 before drawing

A terminal narrower than 12 columns is refused as too small. The picker then returns the same result as a cancel, so the launcher prints the cancel line and exits 130. Widen the terminal and run it again.

Exit 3 at launch

Exit 3 means the endpoint was refused at dispatch (a field that starts with a dash, or an empty field), or the exec itself failed. The message names the binary and, when PHP reports one, the reason. A custom command that is not an executable file is refused the same way.

A duplicate name warning

Names identify endpoints, so two rows with the same name cannot be told apart in the picker. Both still load, and --list suffixes each with its config index (name#2). Rename one of them.

Upstream mapping

The port follows the selection flow of charmbracelet/wishlist: a list, a fuzzy filter, and a connect step. The table maps each part of that flow to the SugarCraft class that carries it. The deliberate differences from upstream are listed in the README.

Upstream flow to SugarCraft class
Flow stepClassNotes
Filterable list of hostsPickerOne-shot raw-mode loop with no event loop. Matching uses sugar-fuzzy's Smith–Waterman scorer.
Endpoint file (YAML or JSON)ConfigA flat top-level list. The parser is shared by the wishlist and the OpenSSH import.
Import from OpenSSH configSshConfigParser, Config::importFromSshConfig()Host patterns become names. The parser reads HostName, User, Port, IdentityFile and ProxyJump, and expands %h, %r and %u.
Connect stepEndpoint, LauncherEndpoint::toSshArgv() builds the argv, and Launcher::dispatch() runs it through pcntl_exec.
Path expansionIdentityPathExpands a leading ~ in identity paths against $HOME, with a passwd fallback.

Architecture

Nine classes carry the program. Config reads a file and turns each row into an Endpoint, a readonly value object whose with*() methods return new instances. SshConfigParser reads the OpenSSH import, and Support\CommentStrip removes trailing comments from both formats. IdentityPath expands ~. Picker renders the rows and reads keys. Launcher builds the final argv and performs the exec through a callable seam, which is how tests observe the handoff without replacing the process. Support\Version reports the version, and Lang wraps the shared SugarCraft\Core\I18n\T catalog for the sshlauncher keys. The bin script ties them together: argument parsing, the trust gate, resolution of the ssh binary and the exit codes.

Changelog and versioning

Releases are tagged candy-ssh-launcher/v*, and a tagged phar stamps its tag into --version. A checkout reports the compiled-in version. The commit history on GitHub is the change record.

Source and demos

Try the quickstart →

Demos.

VHS-recorded GIF of the endpoint picker, regenerated automatically on every push that touches the source.

The endpoint picker listing three hosts under the wishlist banner while a typed filter narrows the list

Picker

Type-filtered SSH endpoint picker — Enter to launch.