lmssh guide

Overview

lmssh links the four OpenSSH 10.6p1 client tools (ssh, sftp, scp, and ssh-keygen), OpenSSL libcrypto, zlib, and the lmcode-cpp bytecode virtual machine into a single static binary. It preserves full interactive compatibility with upstream OpenSSH while providing a strongly typed _lmcode_ host API and the 226-signature lmcode_std_v3 standard library for automated infrastructure workflows.

Single-image OpenSSH architecture and fork isolation

Upstream OpenSSH client tools are designed as short-lived OS processes that mutate global state, install signal handlers, and terminate via exit() or fatal(). Embedding them directly inside a long-running script VM without isolation would corrupt process state. lmssh solves this with a multi-main fork architecture:

Connection multiplexing, secrets, and path hardening

Automated SSH workflows must never hang on unexpected terminal prompts or allow untrusted file names to inject transport commands:

Standard lmcode_std_v3 REST and CLI interfaces

Alongside ssh, keys, io, and report, lmssh embeds the 226-signature lmcode_std_v3 catalog (cpp/stdlib/rest.hpp). Scripts can expose SSH or key-management workflows as HTTP endpoints or structured CLI subcommands:

p = _lmcode_ cli="lmssh" install="github:lmctl-ai/lmssh@latest";
@"--validity"
fn opt_validity(x: RestExchange) -> void implements CliOption {
  x.set("validity", x.query("validity"));
}

@"issue-id"
fn cmd_issue(x: RestExchange) -> void implements CliCommand {
  let n = x.increment("issued");
  x.send(x.body() + ":" + x.get("validity") + ":" + str(n));
}

@"/audit/:principal"
fn get_audit(x: RestExchange) -> void implements RestGet {
  x.json("{\"principal\":\"" + x.param("principal") + "\",\"issued\":\"" + x.get("issued") + "\"}");
}

rest_config("session", "global");
assert_eq(rest_cli(str_split("--validity=+52w issue-id -- alice", " ")), "alice:+52w:1");
assert_eq(rest_cli(str_split("/audit/alice", " ")), "{\"principal\":\"alice\",\"issued\":\"1\"}");
end _lmcode_

Atomic deployment and verification patterns

For zero-downtime file updates across remote hosts, combine io.sha256, Session.put, Session.output, and Session.rename. First compute the local file digest with io.sha256(local_path), upload to a staging path (remote_path + ".new") via s.put, verify the remote sha256sum output matches the local digest, and finally call s.rename(remote_path + ".new", remote_path) to atomically replace the target file on the remote filesystem.