Rotating Your Keypair
The rotate command generates a new keypair for your user account. This is useful for periodic security rotation or if you suspect your private key may have been compromised.
When to rotate
Section titled “When to rotate”Consider rotating your keypair when:
- Periodic security hygiene - Regular key rotation limits exposure
- Suspected compromise - If your private key may have been accessed
- Changing machines - When moving to a new computer
- After a security incident - As part of incident response
Rotating your keypair
Section titled “Rotating your keypair”To rotate your keypair:
kanuka secrets rotateThis prompts for confirmation before proceeding:
Warning: This will generate a new keypair and replace your current one. Your old private key will no longer work for this project.
Do you want to continue? [y/N]: y
Rotating your keypair... Generating new keypair... Decrypting symmetric key with old private key... Re-encrypting symmetric key with new public key... Updating public key in project... Saving new private key...Done: Keypair rotated successfully
Your new public key has been added to the project.Other users do not need to take any action.What happens during rotation
Section titled “What happens during rotation”- Your current private key decrypts the project’s symmetric key
- A new 4096-bit RSA keypair is generated
- The symmetric key is re-encrypted with your new public key
- Your new public key replaces the old one in the project
- Your new private key is saved to your local key store
- Your old private key is overwritten
After rotation:
- You can continue to decrypt secrets with no additional steps
- Other users are unaffected - they keep their existing keys
- The project’s symmetric key remains the same
Skipping confirmation
Section titled “Skipping confirmation”In automated environments, use --force to skip the confirmation prompt:
kanuka secrets rotate --forceRotate examples
Section titled “Rotate examples”# Rotate with confirmation promptkanuka secrets rotate
# Rotate without confirmation (for automation)kanuka secrets rotate --forceUsing with passphrase-protected keys
Section titled “Using with passphrase-protected keys”If your current private key is passphrase-protected, Kānuka will prompt for the passphrase to decrypt the symmetric key.
When generating the new keypair, you can optionally protect it with a passphrase as well.
After rotating
Section titled “After rotating”After rotation:
- Commit the changes - Your new public key needs to be shared
- Push to remote - So the team has your updated public key
git add .kanuka/public_keys/git commit -m "Rotate keypair for $(whoami)"git pushRotation vs sync
Section titled “Rotation vs sync”| Command | What it rotates | Who is affected |
|---|---|---|
rotate | Your personal keypair | Only you |
sync | Project’s symmetric key | All users |
Use rotate for your personal key rotation.
Use sync to rotate the project-wide encryption key for everyone.
Next steps
Section titled “Next steps”- Sync command - Rotate the project’s symmetric key
- Access command - View who has access
- Doctor command - Check project health