Handles Aptos account key rotation with automatic backups, safety checks, and rollback.
aptos-keyrotate wraps aptos account rotate-key with key safety improvements:
- Auto-generates keys - No need to manually generate keys first
- Mandatory backups - Always saves your old key to timestamped backup files
- In-place updates - Updates your profile directly (no profile proliferation)
- Automatic rollback - Restores old key if rotation verification fails
- Verification - Confirms rotation succeeded by checking on-chain auth key and testing profile functionality
curl -fsSL https://raw.githubusercontent.com/ThalaLabs/aptos-keyrotate/main/install.sh | bashThis will download and install aptos-keyrotate to /usr/local/bin.
# Basic rotation (auto-generate new key, backup to ~/.aptos/keyrotate-backups)
aptos-keyrotate --profile my-wallet
# Rotate with specific new key
aptos-keyrotate --profile my-wallet --new-private-key-file ./new-key
# Use custom backup location
aptos-keyrotate --profile my-wallet --backup-dir ~/backups
# Skip confirmation prompts
aptos-keyrotate --profile my-wallet --yesUsage: aptos-keyrotate [OPTIONS]
Options:
--profile PROFILE Existing Aptos CLI profile name (required)
--new-private-key-file FILE Path to new private key (auto-generated if omitted)
--backup-dir DIR Backup directory for old keys (default: ~/.aptos/keyrotate-backups)
--yes Skip confirmation prompts
-h, --help Show this help message
-v, --version Show version information
Safety Features:
• Old private key is ALWAYS backed up before rotation
• Profile is updated in-place with new key after successful rotation
• Automatic rollback if rotation verification fails
- Backup: Creates timestamped backup of your current private key (mandatory)
- Rotate: Executes the on-chain key rotation transaction
- Update: Updates your profile in-place with the new private key
- Verify:
- Checks the on-chain authentication key actually changed
- Tests that the new profile can query account info
- Rollback: If verification fails, automatically restores the old key from backup
Your old private keys are safely stored in the backup directory for recovery if needed.
aptos-keyrotate --profile my-wallet --yes