Skip to content

mongoshield rekey

Add or remove the keys that can decrypt existing backups.

Terminal window
mongoshield rekey [backup] [options]

Rewrites only the age headers of a backup's files (or of its key file), for a new set of recipients, KMS keys or a new passphrase. The data is not re-encrypted, so a removed key that already had a copy of the files can still read them.

ArgumentDescription
[backup]optionalA backup id, "latest", or "all" (default)
OptionDescription
--from <storage-url>Where backups are stored: ./dir, file:///abs, s3://bucket/prefix (default: config).
--add-recipient <age1…>Let this age public key decrypt the backups. Repeatable.
--remove-recipient <age1…>Stop this age public key from decrypting them. Repeatable.
--add-kms <provider:key>KMS backups: add a KMS key, e.g. aws:arn:aws:kms:…. Repeatable.
--remove-kms <provider:key>KMS backups: remove a KMS key (one must remain). Repeatable.
--identity-file <path>age identity file for encrypted backups (from mongoshield keygen). Repeatable.
--passphrase-env <VAR>The CURRENT passphrase, from this variable.
--new-passphrase-env <VAR>Passphrase backups: the new passphrase, from this variable.
--dry-runShow what would change; write nothing.

The global options (--config, --json, --quiet, --verbose, --no-color, --yes) work here too.

Hand backups over to a new ops key and retire the old one:

Terminal window
mongoshield rekey all --add-recipient age1new… --remove-recipient age1old… --identity-file old.key

Change the passphrase of the newest backup:

Terminal window
mongoshield rekey latest --passphrase-env OLD_PASS --new-passphrase-env NEW_PASS