feat(macmini): システム側 sops をホスト鍵で開く - #395
Open
gapul wants to merge 1 commit into
Open
Conversation
macmini はこれまで sops を持たず、restic のパスワードと ntfy の資格情報を 手置きファイルとして宣言の外に置いていた。理由は「人間の age マスター鍵を 無人機に持ち込まない」方針で、これ自体は正しい。あの鍵1つで全秘密が開く。 ホスト鍵での復号はこのトレードオフを消す。/etc/ssh/ssh_host_ed25519_key は 元からこの機械にあり、外に出ず、その age 受信者は secrets/common.yaml にしか 入っていない。必要な分だけ自力で開けて、鍵は1本も運んでいない。 activation は root で走るのでホスト鍵(0600 root:wheel)が読める。home-manager 側では届かないので、システム側に置くのが唯一の方法になる。 置き場所は共通ライブラリの既定パス(手置きだった場所と同じ)なので、 home/macmini-backup.nix は誰が置いたかを知らずに済む。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#393 で入れたホスト鍵の受信者を、実際に使う最初の PR。
なぜ
macmini はこれまで sops を持っていなかった。理由は flake に書いてあるとおり「人間の age マスター鍵を macmini に持ち込まない」方針で、これ自体は正しい判断だった。あの鍵1つでリポジトリの全秘密が開くので、誰も見ていない無人機に置くのは筋が悪い。
代償として、restic のパスワードと ntfy の資格情報が手置きファイルとして宣言の外に residing していた。再インストールのたびに手作業が要るし、何が置いてあるべきかがコードから読めない。
どう解決したか
ホスト鍵で開けばトレードオフが消える。
/etc/ssh/ssh_host_ed25519_keyは元からこの機械にある。新しく運び込む鍵はゼロ。secrets/common.yamlにしか入っていない。darwin.yamlとhomelab.yamlは開けない。なぜシステム側なのか
sops.age.sshKeyPathsが読む先は0600 root:wheelで、home-manager の sops はユーザ権限で動くので届かない。nix-darwin の activation は root で走るため、システム側に置くのが唯一の方法になる。#393 の PR 本文で「次はシステム側」と書いたのはこれのこと。置き場所
restic-common.nixの既定パス(=手置きだった場所と同じ)にそのまま置いた。owner を明示してユーザ所有にしている(バックアップは root ではなくログインユーザで走るため)。場所が変わらないので
home/macmini-backup.nixは誰が置いたかを知らずに済む。変更はコメントの更新だけ。確認
darwinConfigurations.macminiの eval が通るcommon.yamlにあり、darwin.yamlとhomelab.yamlには無いnix fmt差分なし、just docs差分なしマージ後
macmini で
darwin-rebuild switchすると、activation が3つのファイルを上書きする。中身は手置きしてあったものと同じはずだが、もし ntfy のトークンを手元で更新していて sops 側が古いなら、そちらが巻き戻る。先に照合したほうが安全。