I think you could use the sops-nix home-manager integration and something like:
sops = {
secrets.gpg-key = {
mode = "0400";
path = "${config.home.homeDirectory}/.gnupg/private-keys-v1.d/<id>.key";
};
};
Not sure if gpg would pick it up like that though. Might need to then add an activationScript
that rescans that directory or somesuch.
I don’t think you need to copy around the public key, but sharing that is trivial because it doesn’t need to be protected by definition.
Something equivalent would work for SSH, but probably easier because you can configure the path to secrets in ~/.ssh/config
(just manage that file with home-manager and set the paths to ${config.sops.secrets.ssh-key.path}
) and I am fairly sure SSH doesn’t keep a database or anything.
As a side note - if you already have a gpg key you can also use it for ssh, which can be helpful.
That’s a fairly reasonable approach as well; ultimately all of your secrets will need to be protected by some kind of “master” secret anyway, and your gpg/ssh key is a pretty good candidate for that. At least one key will always need to be managed non-declaratively.
If you care about not exposing these secrets, I’d at least recommend not adding the secrets.yaml
to the repository and sharing it independently, as described in the sops-nix docs.
Personally, I use a yubikey to handle all of these secrets, which is both more secure and easier to maintain; sharing your secrets between computers doesn’t get easier than wearing them around your neck. It comes with an additional cost, of course, but they’re well worth it in my opinion.
If you want a low-cost alternative to a yubikey, a LUKS-encrypted USB is also an option, just set your GPGHOME
and stuff to the path you dedicate to mounting your USB stick. It’s significantly less convenient and not nearly as safe as a yubikey, but it probably beats cloud storage.