Complete lab 7 security implementation
This commit is contained in:
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
OUT="${ROOT}/security/openbao-init.json"
|
||||
mkdir -p "$(dirname "$OUT")"
|
||||
|
||||
BAO() {
|
||||
docker compose --env-file "$ROOT/.env" exec -T -e BAO_ADDR=https://127.0.0.1:8200 -e BAO_CACERT=/openbao/certs/ca.crt openbao \
|
||||
bao "$@"
|
||||
}
|
||||
|
||||
echo "==> OpenBao init (3 shares, threshold 2)"
|
||||
BAO operator init -key-shares=3 -key-threshold=2 -format=json > "$OUT"
|
||||
|
||||
chmod 600 "$OUT"
|
||||
|
||||
echo "==> Unseal (2 из 3 keys)"
|
||||
for i in 0 1; do
|
||||
key=$(jq -r ".unseal_keys_b64[$i]" "$OUT")
|
||||
BAO operator unseal "$key" >/dev/null
|
||||
done
|
||||
|
||||
echo "==> Login root"
|
||||
jq -r '.root_token' "$OUT" > "${ROOT}/security/root-token.txt"
|
||||
chmod 600 "${ROOT}/security/root-token.txt"
|
||||
|
||||
echo "==> OpenBao initialized and unsealed."
|
||||
echo " Init file: $OUT (chmod 600) — перенеси в защищённое хранилище и удали"
|
||||
echo " Root token: ${ROOT}/security/root-token.txt (chmod 600)"
|
||||
echo " Unseal keys: 3 shares, нужно 2 для unseal после рестарта"
|
||||
Reference in New Issue
Block a user