Add sessions-ctl keygen to create prod's key on the dev box

keygen generates an ed25519 pair in RAM, writes the public half to
config.toml and authorized_keys (replacing the previous sessions-manager
line) and prints the web app's environment - dev host, port, user, pinned
host key and the private key as one base64 line - then deletes the private
key, so the pasted copy is the only one. Refuses to replace an existing key
without --rotate. Local only, never reachable over SSH.

Also make load_config() read CONFIG_PATH at call time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KKYfRST9cTJYae3f7Jf3ac
This commit is contained in:
agent 2026-09-30 14:39:56 +00:00
parent 08636ddc25
commit ca66db3aeb
4 changed files with 165 additions and 7 deletions

View file

@ -24,7 +24,7 @@ done
if [[ ! -e "$cfg_dir/config.toml" ]]; then
install -m 600 "$here/config.example.toml" "$cfg_dir/config.toml"
echo "created $cfg_dir/config.toml — edit [repos] and [ssh_access], then re-run."
echo "created $cfg_dir/config.toml — edit [repos] and [ssh_access], then run: sessions-ctl keygen"
fi
chmod 600 "$cfg_dir/config.toml"
@ -41,6 +41,6 @@ fi
if grep -Eq '^public_key = "ssh-[a-z0-9-]+ AAAA[A-Za-z0-9+/=]{20,}' "$cfg_dir/config.toml"; then
"$bin/sessions-ctl" refresh-access
else
echo "ssh_access.public_key not set yet — skipping authorized_keys."
echo "no key for prod yet — run: sessions-ctl keygen"
fi
echo "installed. try: sessions-ctl health"