Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tor: hidden services can bring-their-own-key #93804

Closed
wants to merge 1 commit into from

Conversation

colemickens
Copy link
Member

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's hs_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
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@colemickens
Copy link
Member Author

Maybe it would be better to write a script that uses the Tor socket api to create the service using the key data directly?

@colemickens
Copy link
Member Author

note to self, per mic92's suggestion:

"f /etc/munge/munge.key 0400 munge munge - mungeverryweakkeybuteasytointegratoinatest"

ok, from my perspective you are just copying a new file, which should be doable with systemd-tmpfiles

@stale
Copy link

stale bot commented Jun 4, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 4, 2021
@colemickens
Copy link
Member Author

I have some recollection that someone did this and tailscale more or less fulfills any reason I was ever curious about this. Closing.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 24, 2023
@colemickens colemickens deleted the tor-hs-byok branch October 2, 2023 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants