targets/ssh MUST run the system's OpenSSH client through proc and nothing else: no SSH protocol code and no library of one (ssh2 and the like MUST NOT be imported); the remote command MUST be quoted word by word into ONE argument, because ssh joins what follows the host into a string for the remote shell (a word is left as it is where it needs no quoting, otherwise in single quotes with each single quote written '\'', and a word with a NUL is refused); the options every call needs MUST be set in that one place: -T, BatchMode=yes, ConnectTimeout (10 seconds), ServerAliveInterval (15 seconds), no password and no keyboard-interactive prompt, a shared connection (ControlMaster, ControlPath, ControlPersist) where a folder is given, the key by reference (IdentitiesOnly, -i), the port and the jump chain, and -- before the destination; a script MUST run as sh -s -- <args> with the script on the standard input. A call that cannot be made MUST be an exit of 255 with the reason, as a connection that did not happen. Taken from: stolos's ssh calls (BatchMode=yes, ConnectTimeout=10, ServerAliveInterval=15, -T, ssh <host> sh -s).
Enforced (check): .github: cd commons/headless && bun run verify — suite/reach-targets.test.ts: the remote command is quoted word by word into one string that a real shell reads back as the same words; suite/reach-targets.test.ts: the ssh arguments hold the one set of options in one place, put the destination after --, and never accept a host key; suite/reach-targets.test.ts: an address that could be taken for an option, a user, a port, a jump or a credential that is not one is not a target; suite/reach-targets.test.ts: the ssh executor runs the system's client with the quoted command, gives a call that cannot be made as 255 and runs a script as sh -s with it on the input
Proved by: headless/suite/reach-targets.test.ts
Written in: headless/src/logical/remote.ts, headless/src/targets/ssh/argv.ts, headless/src/targets/ssh/executor.ts, headless/src/targets/ssh/mod.ts
Tests: passed: suite/reach-targets.test.ts the ssh arguments hold the one set of options in one place, put the destination after --, ; passed: suite/reach-targets.test.ts an address that could be taken for an option, a user, a port, a jump or a credential that ; passed: suite/reach-targets.test.ts the remote command is quoted word by word into one string that a real shell reads back as ; passed: suite/reach-targets.test.ts the ssh executor runs the system's client with the quoted command, gives a call that canno
Cited by: Headless, targets/ssh/argv, targets/ssh/executor