Skip to content

deploy: install-key.sh — put a secret into the VM's env file over SSH, stdin only - #20

Open
luiscota99 wants to merge 1 commit into
mainfrom
feat/deploy-install-key
Open

luiscota99 wants to merge 1 commit into
mainfrom
feat/deploy-install-key

Conversation

@luiscota99

Copy link
Copy Markdown
Owner

Summary

deploy/install-key.sh: the operator runs it on their own machine to put an API key into /etc/engram/engram.env on the hub VM without the key appearing in a shell argument, a log, or a chat transcript.

  • Reads the key from a local file (default ~/Documents/engram-hub-key.txt, line 1), refuses the placeholder, refuses a non-sk-ant- value for ENGRAM_LLM_API_KEY, refuses whitespace/quotes. Never echoes it.
  • Over SSH with sudo -n: creates /etc/engram if missing, installs deploy/engram.env.example if the env file is missing (0640 root:engram, or root:root until the engram group exists), replaces the one VAR= line with the value from stdin, restarts engram-serve only if it is running.
  • Deletes the local file afterwards (shred/rm -P) unless --keep. --dry-run prints the plan and sends nothing. --var ENGRAM_EMBED_API_KEY --key-file … installs a second secret the same way.
  • deploy/README.md step 2 documents it beside the on-VM alternative.

Verification

  • bash -n parses; shellcheck not installed locally
  • tests/test_deploy_files.py: dry run output never contains the key, names host/path/length; placeholder → exit 2; non-Anthropic value → exit 2 without echoing it; bad var name → exit 2
  • Probed the real VM read-only first: hub user has passwordless sudo, Ubuntu 26.04, Python 3.14, Engram not yet installed — the script's "template if missing / root:root until the group exists" branches are for exactly that state

🤖 Generated with Claude Code

…, stdin only

The operator runs it on their own machine. The value is read from a local
file (default ~/Documents/engram-hub-key.txt), validated (placeholder
refused; ENGRAM_LLM_API_KEY must be sk-ant-…; no whitespace/quotes), and
sent to the VM on stdin — never as an argument, never echoed, never in a
log or a transcript. On the VM (sudo -n): create /etc/engram if missing,
install deploy/engram.env.example if the env file is missing (0640
root:engram, or root:root until the engram group exists), replace the one
VAR= line, restart engram-serve only if it is running. The local file is
deleted afterwards unless --keep. --dry-run shows the plan and sends
nothing; --var/--key-file install a second secret (Gemini) the same way.

Test: bash -n, dry run never prints the key, placeholder and non-sk-ant
values refused with exit 2, bad var name refused.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant