From 8f818a64f2f0f3a833fc842d52a675358ec64c9c Mon Sep 17 00:00:00 2001 From: Igor Soarez Date: Wed, 18 Nov 2026 14:02:09 +0000 Subject: szecret: buckets beside the old store -- get/has/put/mv/rekey/list/check/enrol, admins from SZECRET_ADMINS_COMMAND; rotate retired (fleet hardening 12) A bucket is a directory of secrets with one set of readers: its recipients file plus the admins, the full set recorded in .szecret by rekey. put refuses when the readers or admins drift from that set, or with no admins; a plain put of a new name goes to admin-only, one still in the old store is rewritten there. The old store keeps working throughout. link/claude.sh leaves out an MCP server whose secret is in a bucket this host doesn't read. Design: cloud-setup docs/proposal-secret-roles.md. --- secrets/rotate.sh | 119 ------------------------------------------------------ 1 file changed, 119 deletions(-) delete mode 100755 secrets/rotate.sh (limited to 'secrets/rotate.sh') diff --git a/secrets/rotate.sh b/secrets/rotate.sh deleted file mode 100755 index 4286f4c..0000000 --- a/secrets/rotate.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -if [[ "$#" -gt 0 && ("$1" == "-h" || "$1" == "--help") ]]; then - cat <&2 echo "ERROR: Unknown argument: $1" - exit 1 -fi - -ensure_age -ensure_private_key - -old_private_key="${private_key}" -old_public_key="${key_id}" - -shopt -s nullglob -store_files=("${store}"/*.age) -shopt -u nullglob -secret_count="${#store_files[@]}" - -if [[ "${assume_yes}" != "true" ]]; then - if [[ ! -t 1 ]]; then - >&2 echo "ERROR: rotate requires interactive confirmation (use --yes to skip)" - exit 1 - fi - >&2 echo "This will generate a new age key and re-encrypt ${secret_count} secret(s)." - >&2 echo "Current public key: ${old_public_key}" - >&2 printf "Continue? [y/N] " - local_confirm="" - read -r local_confirm &2 echo "Aborted." - exit 1 - fi -fi - -staging="$(mktemp -d "${TMPDIR:-/tmp}/szecret-rotate.XXXXXX")" -temp_private_key="$(mktemp -u "${TMPDIR:-/tmp}/szecret-rotate-key.XXXXXX")" -temp_public_key="$(mktemp "${TMPDIR:-/tmp}/szecret-rotate-pub.XXXXXX")" - -cleanup() { - rm -rf "${staging}" - rm -f "${temp_private_key}" "${temp_public_key}" -} -trap cleanup EXIT - -age-keygen -o "${temp_private_key}" 2>/dev/null -new_public_key="$(age-keygen -y "${temp_private_key}")" -echo "${new_public_key}" > "${temp_public_key}" - -for secret_file in "${store_files[@]}"; do - secret_name="$(basename "${secret_file}" .age)" - age_decrypt "${old_private_key}" "${secret_file}" \ - | age_encrypt "${temp_public_key}" "${staging}/${secret_name}.age" -done - -for secret_file in "${store_files[@]}"; do - secret_name="$(basename "${secret_file}" .age)" - mv "${staging}/${secret_name}.age" "${secret_file}" -done - -echo "${new_public_key}" > "${public_key}" - -installed_private_key="${private_key_dir}/${new_public_key}" -mv "${temp_private_key}" "${installed_private_key}" -temp_private_key="" -chmod 600 "${installed_private_key}" 2>/dev/null || true - -cat <