lmssh reference
Complete command-line flag reference, embedded OpenSSH client subcommands, host schema contexts and methods, standard lmcode_std_v3 REST and CLI interfaces, and exit codes for lmssh v0.1.1 (bundling OpenSSH 10.6p1).
Host and CLI flags
| Flag or command | Arguments | Description |
|---|---|---|
| --version | none | Print the lmssh version string (lmssh 0.1.1) and exit 0. |
| --lmcode | <file.dslb>... [-- args...] | Load and execute one or more compiled LMScript bytecode files; arguments after -- are exposed via io.args(). |
| --dry-run | --lmcode <file.dslb> | Print every ssh, sftp, scp, and ssh-keygen command to stderr as [dry-run] without spawning processes or modifying local files. |
| --lmcode-schema | [--json] | Print a human-readable schema signature summary, or exact embedded schema JSON bytes when --json is passed. |
| --lmcode-signatures | none | Print all 334 canonical context, function, and method signatures (108 host + 226 standard library). |
| ssh | [openssh-args...] | Run the embedded OpenSSH 10.6p1 ssh client (also invoked when argv[0] is ssh or argv[1] starts with a single -). |
| sftp | [openssh-args...] | Run the embedded OpenSSH 10.6p1 sftp client using the lmssh binary as its underlying ssh transport. |
| scp | [openssh-args...] | Run the embedded OpenSSH 10.6p1 scp client using the lmssh binary as its underlying ssh transport. |
| ssh-keygen / keygen | [openssh-args...] | Run the embedded OpenSSH 10.6p1 ssh-keygen utility. |
Ssh, Session, Result, and ResultList methods
| Type / context | Method signature | Description |
|---|---|---|
| context ssh: Ssh | ssh.connect(string) -> Session | Create a Session for [user@]host or an ssh_config alias, inheriting current Ssh defaults. |
| Ssh | ssh.each(StrList, string) -> ResultList | Execute a command across all destinations in parallel (up to parallel(n)) and return results in input order. |
| Ssh | ssh.shutdown() -> void | Close all active ControlMaster multiplex sockets and remove the temporary work directory early. |
| Ssh / Session | port(int) | user(string) | identity(string) | config(string) | jump(string) -> Ssh / Session | Configure SSH port (-p/-P), default user, identity key file (-i with IdentitiesOnly=yes), config file (-F), or ProxyJump (-J). |
| Ssh / Session | known_hosts(string) | strict_host_key(string) | option(string) -> Ssh / Session | Set UserKnownHostsFile, StrictHostKeyChecking (yes, accept-new, no), or repeatable -o Key=Value options. |
| Ssh / Session | connect_timeout(int) | timeout(int) | password(string) | reuse(bool) | parallel(int) -> Ssh / Session | Set ConnectTimeout seconds (default 30), per-step wall timeout seconds, askpass secret, ControlMaster reuse, or fan-out concurrency (1..256). |
| Session | s.exec(string) -> Result | s.exec(string, string) -> Result | Run a remote command (optionally piping the second argument to stdin) and return a Result without throwing on non-zero exit status. |
| Session | s.output(string) -> string | s.ok(string) -> bool | Run a remote command and return stdout (throwing RUN_HOST if exit status != 0) or return true on exit status 0. |
| Session | s.put(string, string) | s.get(string, string) | s.put_dir(string, string) | s.get_dir(string, string) -> void | Upload or download a single file or recursive directory via scp, throwing RUN_HOST on failure. |
| Session | s.cat(string) -> string | s.write(string, string) -> void | Read a remote file into a string or write string content to a remote file via a private temporary file and scp. |
| Session | s.ls(string) -> StrList | s.exists(string) -> bool | s.mkdir(string) | s.rm(string) | s.rmdir(string) | s.rename(string, string) -> void | Inspect or mutate remote filesystem paths over an SFTP batch session with wildcard-neutralized literal paths. |
| Session | s.sftp(string) -> Result | s.close() -> void | s.dest() -> string | Run a raw SFTP batch script on stdin (stripping sftp> echo lines), close this session's ControlMaster, or return the destination string. |
| Result | r.ok() -> bool | r.status() -> int | r.stdout() -> string | r.stderr() -> string | r.dest() -> string | r.timed_out() -> bool | r.require() -> Result | Inspect remote execution status (status 124 on timeout) or throw RUN_HOST if the command failed or timed out. |
| ResultList | rl.len() -> int | rl.at(int) -> Result | rl.failed() -> int | rl.require_all() -> ResultList | Inspect parallel fleet execution results or throw RUN_HOST listing every failed destination. |
Keys, Key, Io, and Report methods
| Type / context | Method signature | Description |
|---|---|---|
| context keys: Keys | keys.bits(int) -> Keys | Set the key bit length (-b) for subsequent keys.generate calls. |
| Keys | keys.generate(string, string) -> Key | keys.generate(string, string, string, string) -> Key | Generate a new SSH key at path with type (ed25519, rsa, ecdsa) and optional comment and passphrase; refuses to overwrite existing files. |
| Keys | keys.load(string) -> Key | keys.fingerprint(string) -> string | Load an existing key metadata handle or return the SHA256:... fingerprint string of a key or certificate file. |
| Keys | keys.change_passphrase(string, string, string) | keys.set_comment(string, string, string) -> void | Update a private key's passphrase (-p) or comment (-c) via ssh-keygen. |
| Keys | keys.known_hosts_find(string, string) -> string | keys.known_hosts_remove(string, string) | keys.known_hosts_hash(string) -> void | Find (-F), remove (-R), or hash (-H) host entries in a known_hosts file. |
| Keys | keys.certify(string, string, string, string, string) -> string | Sign a public key with a CA key (ca_key, pub_key, identity, principals, validity) and return the *-cert.pub path. |
| Keys | keys.sign(string, string, string) -> string | keys.verify(string, string, string, string, string) -> bool | Create a detached signature (key, namespace, file -> file.sig) or verify a signature against an allowed_signers file (-Y sign / -Y verify). |
| Key | k.path() | k.public() | k.public_with(string) | k.fingerprint() | k.type() | k.comment() -> string | k.bits() -> int | Inspect key path, OpenSSH public key line (from .pub or derived with passphrase), SHA256 fingerprint, algorithm type, comment, or bit size. |
| context io: Io | io.print(string) | io.eprint(string) | io.fail(string) -> void | Write a line to stdout or stderr, or terminate the script with APP_FAIL (exit code 4). |
| Io | io.read(string) -> string | io.lines(string) -> StrList | io.write(string, string) | io.append(string, string) -> void | Read a local file as a string or line list, or write/append string content to a local path. |
| Io | io.exists(string) -> bool | io.mkdir(string) | io.remove(string) -> void | io.temp_dir() -> string | Check local path existence, recursively create or delete directories, or allocate an auto-cleaned private temporary directory. |
| Io | io.env(string) -> string | io.args() -> StrList | io.sha256(string) -> string | io.sleep_ms(int) -> void | io.now() -> int | Read an environment variable, script arguments after --, lowercase hex SHA-256 of a local file, sleep in ms, or read epoch seconds. |
| context report: Report | report.add(string, string, int, string) -> void | report.count() -> int | report.text() -> string | Record a structured finding (kind, host_or_file, status_or_line, message), count findings, or format findings as text. |
| Report | report.print() | report.write_text(string) | report.write_json(string) | report.fail_if_any() -> void | Print findings, export text or JSON finding reports, or exit with code 4 (APP_FAIL) if count() > 0. |
Standard lmcode_std_v3 REST and CLI interfaces
| Interface or function | Signature / annotation | Description |
|---|---|---|
| RestGet .. RestOptions | @"/path/:param" fn h(x: RestExchange) -> void implements RestGet | Bind an HTTP GET, POST, PUT, DELETE, PATCH, HEAD, or OPTIONS route handler. |
| RestHandler | @"/path" fn h(x: RestExchange) -> void implements RestHandler | Bind a method-agnostic HTTP route handler. |
| CliCommand | @"cmd" fn h(x: RestExchange) -> void implements CliCommand | Bind a named CLI subcommand dispatched by rest_cli. |
| CliOption | @"--flag" fn h(x: RestExchange) -> void implements CliOption | Bind a CLI option flag (--flag=val or --flag val) evaluated before the command handler. |
| rest_config | rest_config(key: string, value: string) -> void | Configure server or CLI settings such as host, port, and session (ephemeral or global). |
| rest_route | rest_route(method: string, path: string, handler: string) -> void | Dynamically register an HTTP method and route pattern to a handler function name. |
| rest_serve / rest_stop | rest_serve() -> void | rest_stop() -> void | Start or stop the embedded standard HTTP server loop. |
| rest_cli | rest_cli(args: StrList) -> string | Dispatch CLI options, commands, or path requests in-process without opening a socket. |
| RestExchange | x.method() | x.path() | x.body() | x.param(string) | x.query(string) | x.header(string) -> string | Read request method, path, body, :param segment, query parameter, or header. |
| RestExchange | x.has_query(string) | x.has_header(string) -> bool | Check whether a query parameter or request header is present. |
| RestExchange | x.status(int) | x.set_header(string, string) | x.send(string) | x.json(string) -> void | Set response status code and headers, and emit plain text or application/json bodies. |
| RestExchange | x.get(string) -> string | x.set(string, string) -> void | x.increment(string) -> int | Read, write, or atomically increment session state keys across global or ephemeral exchanges. |
Exit codes
| Exit code | Category | Meaning |
|---|---|---|
| 0 | Success | Bytecode program or introspection command succeeded and all assertions passed. |
| 2 | Usage error | Invalid command-line flag, missing --lmcode file argument, or malformed invocation. |
| 3 | Load / host run error | Bytecode corrupt, schema hash mismatch, unbound import, or runtime host error (RUN_HOST). |
| 4 | Application verdict | Script explicitly failed via io.fail(msg), report.fail_if_any(), or an assertion failure (APP_FAIL). |
| 0..255 | Direct OpenSSH mode | When invoked as lmssh ssh|sftp|scp|ssh-keygen, returns the exact exit code of the OpenSSH client tool. |