feat(atuin): E2E 暗号鍵を sops に入れる - #400
Merged
Merged
Conversation
~/.local/share/atuin/key はどこにもバックアップされていなかった (2025-06-24 作成、76バイト、ローカルに1部だけ)。これが失われると同期済みの履歴を復号できない。 置き場所は Bitwarden ではなく sops。人間が打つものではなく atuin が決まった パスから読むファイルなので、sops-nix の担当。載せておけば新しい端末でも rebuild だけで正しい場所に置かれ、手でコピーする手順が消える。既に unified_calendar/ntfy_url が ~/.config/ntfy/url に対して同じことをしている。 Bitwarden 側に要るのは atuin の**パスワード**のほうで、あれは login のときに 人間が打つもの。混ぜていたので cli.nix のコメントも直した。 mode は 0400 ではなく 0600。0400 だと atuin login が書き戻そうとして失敗する。 sops が正なので、login が別の鍵を書いても次の activation で戻る。 値は出さずにハッシュだけで往復を検証済み (元の鍵と sops から復号した鍵が一致)。
atuin login で使うもの。鍵と違ってファイルとして読まれるわけではないので path は指定していない。Bitwarden にも入れておくと母艦が壊れているとき手で 打てるが、正は sops。
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.
「Bitwarden じゃなくて sops じゃない?」の指摘どおりでした。#399 のコメントで Bitwarden と書いたのは間違いです。
なぜ sops なのか
atuin の鍵は人間が打つものではなく、atuin が決まったパスから読むファイルです。これは sops-nix の担当で、載せておけば新しい端末でも rebuild だけで
~/.local/share/atuin/keyに materialise されます。手でコピーする手順が消える。既に同じ形の前例がありました。
Bitwarden が要るのは atuin のパスワードのほうで、あれは
atuin loginで人間が打つものです。別物なのを混ぜていました。cli.nixのコメントも直しました。背景
この鍵は 2025-06-24 作成の76バイトで、ローカルに1部しかありませんでした。失われると api.atuin.sh に同期済みの履歴が復号できなくなります。
cli.nixのコメントには前から「Bitwarden に退避しておくこと」と書いてありましたが、実際には退避されていませんでした。自前サーバーへの移行とは独立に、今の時点で単一障害点だったので、そこも同時に埋まります。
mode について
0400ではなく0600にしてあります。0400だとatuin loginが書き戻そうとして permission denied になるためです。sops が正なので、login が別の鍵を書いても次の activation で戻ります。鍵を変えるときは
secrets/common.yamlを更新するのが正しい手順になります。検証
値を出さずにハッシュだけで往復を確認しました。
sops.secrets."atuin/key"が{path: ~/.local/share/atuin/key, mode: 0600}で eval されることも確認済みです。