Skip to content

Backing Up Your Onion Address

Sam Bent edited this page Nov 15, 2026 · 7 revisions

Backing Up Your Onion Address

Your .onion address is a private key on disk. Keep the key and you keep the address forever. Lose it and the address is gone for good. There is no recovery. Backing up the key is the most important operational rule in this wiki.

What the address is

When you started HiddenForge, it created a folder for your service inside the directory you mounted (in the Quickstart, that's ./tor-keys). Inside it:

tor-keys/mysite/
├── hostname                 # your .onion address, in plain text
├── hs_ed25519_secret_key    # the private key: THIS is the address
└── hs_ed25519_public_key

The hostname file is just a readable copy of the address. The address is really hs_ed25519_secret_key. Whoever has that file controls the address; whoever loses it loses the address.

If you turned on key encryption at rest (hiddenforge setup --encrypt-keys), the folder holds hs_ed25519_secret_key.enc instead of the plaintext key. That sealed key is useless without its passphrase, so the passphrase is part of the backup: store it somewhere other than the key folder, because without it the address is gone.

Back it up now

Once the container has started, each service folder belongs to the container's tor user and is private (mode 0700), so your own account can't read the key. A plain tar as yourself would fail on it or, worse, leave it out. Use the hiddenforge CLI (see the README); it encrypts the archive and refuses to write one that is missing a key:

# Docker: run it as root so it can read the tor-owned folders
sudo hiddenforge backup --keys ./tor-keys --out ./keys-backup.tar.age

# rootless Podman: run it inside Podman's user namespace instead
podman unshare hiddenforge backup --keys ./tor-keys --out ./keys-backup.tar.age

backup writes nothing, and says why, when:

  • it cannot read every file in the key folder (run it as root, or under podman unshare);
  • the folder contains a symbolic link (it names the link rather than leave that service out of the archive);
  • the folder is empty, or larger than 512 MB;
  • the folder holds a key in none of its three forms: hs_ed25519_secret_key, the sealed hs_ed25519_secret_key.enc, or an encrypt-key envelope;
  • a file named hs_ed25519_secret_key.enc is not a sealed key.

A sealed key goes into the backup still sealed, so restoring it gives back a key that still needs its own passphrase as well as the backup's.

It uses age (asks for a passphrase) or gpg (--tool gpg --passphrase-file FILE, for scripts). age always produces authenticated encryption; gpg does when it supports AEAD, and otherwise falls back to CFB with an integrity check unless you pass --require-aead, which refuses that fallback. Unauthenticated openssl encryption is refused.

Then move that file off the server, to storage you control. Treat it like the private key it is:

  • Encrypt it. Anyone who reads hs_ed25519_secret_key can impersonate your service.
  • Keep it offline. Don't leave the only copy on the same machine that's serving it.
  • Don't email it, paste it, or sync it to a third-party cloud in the clear.

Restoring

To bring an address back on a new machine, restore the key folder before you start the container:

mkdir -p tor-keys
hiddenforge restore --keys ./tor-keys --input ./keys-backup.tar.age

(Prefix it with sudo, or podman unshare, when restoring into a key folder a container has already used.) A file that was never encrypted, for instance one swapped in for your backup, is refused before anything is written, and for a gpg backup restore reports whether it was aead or cfb.

restore refuses to overwrite existing keys unless you pass --force, and even then it moves each file it would replace into a sibling folder, <keys>.replaced-<timestamp>, rather than deleting it. It also removes the published <name>.onion copy of every service it restores, so that file never names an old address; the container writes it again once the restored service is reachable. HiddenForge never overwrites an existing key either, so the container picks up the restored key and serves the same .onion as before; the project's tests check that a backup restores to the same address.

Choosing your address in advance (optional, higher-effort)

By default the address is random. If you want a specific prefix (a "vanity" address), or you don't want the key ever generated on the serving machine, you can create the key elsewhere and mount it:

  • Generate a vanity key offline with the generator built into the image: hiddenforge vanity --prefix <prefix> --name <service> --keys ./tor-keys. --bench first tells you how long a prefix will take on your machine and generates nothing; every extra character multiplies it by 32. The generator runs in a container with no network. A prefix is 1 to 12 characters from a-z and 2-7. Or generate an ordinary key on an air-gapped machine.
  • Place the resulting hs_ed25519_secret_key (with its public key and hostname) into tor-keys/<service>/ before the first start. HiddenForge makes a folder you created private and hands it to Tor itself.

This keeps the private key from ever being created on the internet-connected host, which matters if your threat model includes the serving machine being seized or compromised.

The one thing to remember

If you take nothing else from this wiki: back up the key folder, encrypted and offline, before you tell anyone your address. Everything else here can be rebuilt. That can't.

Clone this wiki locally