docs(secrets,shell): document two-tier secrets model and operator CLI wrappers
- Document Two-Tier Secrets Architecture separating Workstation Operator Secrets (Config/secrets.yaml) from Server Runtime Secrets (Core/nixos/secrets.yaml) - Document flarectl and hostinger transparent in-memory secret wrappers in docs/reference/shell.md
This commit is contained in:
1 parent
df77c3ef6f
commit
1ceeca785f
2 files changed
+60
-12
No files matched your search
+10
-1
@@ -13,7 +13,7 @@ The shell environment is modularized:
|
||||
- `jump.sh`: Directory navigation and quick jumping.
|
||||
- `pdf.sh`: PDF compilation, viewing, and OCR helpers.
|
||||
- `quicklinks.sh`: Shortcuts to primary project directories.
|
||||
- `secrets.sh`: SOPS secret retrieval and Wayland clipboard extraction (`gh-token`).
|
||||
- `secrets.sh`: SOPS secret retrieval (`gh-token` clipboard utility, transparent `flarectl` and `hostinger` process wrappers).
|
||||
- `todo.sh`: Lightweight terminal task tracking.
|
||||
- `wayland.sh`: Wayland session environment variables and clipboard helpers.
|
||||
|
||||
@@ -39,6 +39,15 @@ The shell environment is modularized:
|
||||
| `gl` | `git log --oneline --graph --decorate` | Compact visual commit graph. |
|
||||
| `ght` | `gh-token` | Copy GitHub repo token from SOPS into Wayland clipboard. |
|
||||
|
||||
### Operator CLI Secret Wrappers (`home/shell/secrets.sh`)
|
||||
| Command / Function | Injected Environment Variables | Source Secret Key (`~/Config/secrets.yaml`) |
|
||||
| :--- | :--- | :--- |
|
||||
| `flarectl` | `CF_API_TOKEN`, `CF_ACCOUNT_ID` | `["cloudflare"]["api_token"]`, `["cloudflare"]["account_id"]` |
|
||||
| `hostinger` | `HOSTINGER_API_TOKEN` | `["hostinger"]["api_token"]` |
|
||||
| `gh-token` (`ght`) | *(Copies directly to Wayland clipboard)* | `["system"]["gh_repo_token"]` (from Homelab `Core`) |
|
||||
|
||||
*Note: Environment variables are set exclusively for the child process lifecycle and do not persist in your interactive shell.*
|
||||
|
||||
### Directory Navigation Jumps (`home/shell/jump.sh`)
|
||||
| 2-Letter | Word Alias | Target Directory | Description |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
|
||||
+50
-11
@@ -32,19 +32,58 @@ graph LR
|
||||
end
|
||||
```
|
||||
|
||||
### Roles & Boundaries
|
||||
1. **Workstation (`Config`)**:
|
||||
- Holds **zero** declarative system secrets (`sops-nix` is not imported).
|
||||
- Provides operator CLI packages (`sops`, `age`, `rbw`) in `home/dev.nix`.
|
||||
- Stores the operator's personal age identity in `~/.config/sops/age/keys.txt`.
|
||||
2. **Server (`Core`)**:
|
||||
- Headless consumer running Docker containers, databases, and Traefik.
|
||||
- Decrypts secrets at boot into a secure ramfs (`/run/secrets/`) using `/etc/ssh/ssh_host_ed25519_key`.
|
||||
- Unprivileged SSH sessions cannot edit secrets directly on the server.
|
||||
### Two-Tier Secrets Architecture
|
||||
|
||||
The infrastructure enforces a strict separation between **Operator Secrets** (workstation) and **Runtime Workload Secrets** (server):
|
||||
|
||||
| Attribute | Workstation Operator Secrets (`Config`) | Server Runtime Secrets (`Core`) |
|
||||
| :--- | :--- | :--- |
|
||||
| **Ciphertext File** | `Config/secrets.yaml` | `Core/nixos/secrets.yaml` |
|
||||
| **Scope** | Personal operator tokens (Cloudflare, Hostinger, GitHub) | Service runtime credentials (Traefik, DBs, Docker daemons) |
|
||||
| **Tenancy** | Multi-project across account domains | Scoped strictly to homelab infrastructure workloads |
|
||||
| **Decryption Model** | In-memory on-demand via `sops -d --extract` in shell wrappers | Automated boot-time ramfs mount via `sops-nix` (`/run/secrets/`) |
|
||||
| **Key Identity** | Personal age identity (`~/.config/sops/age/keys.txt`) | Server host SSH key (`/etc/ssh/ssh_host_ed25519_key`) |
|
||||
| **Daemon Overhead** | **Zero** (`sops-nix` module intentionally omitted) | Managed via root systemd units |
|
||||
|
||||
---
|
||||
|
||||
## 2. Operator Workflow: Authoring & Rotating Secrets
|
||||
## 2. Workstation Operator Secrets (`Config/secrets.yaml`)
|
||||
|
||||
Operator CLI tools (such as `flarectl` and `hostinger`) manage cloud infrastructure across multiple projects. To maintain least-privilege for the server, these credentials are kept on the workstation:
|
||||
|
||||
```yaml
|
||||
# Config/secrets.yaml (encrypted with operator age key)
|
||||
cloudflare:
|
||||
api_token: "..."
|
||||
account_id: "..."
|
||||
|
||||
hostinger:
|
||||
api_token: "..."
|
||||
```
|
||||
|
||||
### Process-Scoped In-Memory Decryption
|
||||
Rather than exporting tokens into global interactive shells or writing plaintext config files to disk, shell wrappers in `home/shell/secrets.sh` extract credentials into the child process environment on demand:
|
||||
|
||||
```bash
|
||||
# Example: flarectl wrapper in home/shell/secrets.sh
|
||||
flarectl() {
|
||||
local secrets_file="$HOME/Config/secrets.yaml"
|
||||
if [[ -f "$secrets_file" ]] && command -v sops >/dev/null 2>&1; then
|
||||
CF_API_TOKEN=$(sops -d --extract '["cloudflare"]["api_token"]' "$secrets_file" 2>/dev/null) \
|
||||
CF_ACCOUNT_ID=$(sops -d --extract '["cloudflare"]["account_id"]' "$secrets_file" 2>/dev/null) \
|
||||
command flarectl "$@"
|
||||
else
|
||||
command flarectl "$@"
|
||||
fi
|
||||
}
|
||||
```
|
||||
|
||||
* **Security**: Decryption occurs strictly in RAM (~17ms overhead).
|
||||
* **Isolation**: The environment variables exist only for the life of `flarectl "$@"` and do not persist in the parent interactive shell.
|
||||
|
||||
---
|
||||
|
||||
## 3. Homelab Server Runtime Secrets (`Core/nixos/secrets.yaml`)
|
||||
|
||||
To rotate or add a secret for homelab services:
|
||||
|
||||
@@ -74,7 +113,7 @@ The server evaluates the new ciphertext, decrypts it into `/run/secrets/`, and r
|
||||
|
||||
---
|
||||
|
||||
## 3. Backing Up & Restoring the Operator Age Key
|
||||
## 4. Backing Up & Restoring the Operator Age Key
|
||||
|
||||
The operator key is your cryptographic identity for managing homelab infrastructure:
|
||||
|
||||
|
||||
Reference in new issue
Block a user