tor: hidden services can bring-their-own-key #93804
Closed
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.
Motivation for this change
This change adds a new script to run before Tor starts. For any hidden services, if they have a predefined
keyPath
, it will be copied and used as the hidden service'shs_ed25519_secret_key
.In this way, you can generate Tor hidden service keys, encrypt them with sops-nix, embed them into an image, and have them securely, automatically boot into serving a given hidden site.
This is particularly nice because you can now effectively predictably automate a NAT-hole punch with a "stateless" static image, in conjunction with any unlocker that sops supports (Azure KeyVault, KMS, GPG, etc).
For reviewers: please advise on other options for how I can prevent copying the private key to the torDirectory. I am using
sops-nix
, and I'm not sure what the problem was, but I could not get any sort of symlink to work, no matter how much I ensure the permissions were exactly correct.But, I really don't like copying the private key to disk, especially when
sops-nix
goes so far out of its way to keep it off disk. I think I may need to try to consult with the Tor folks to see if is particular in this regard.Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)