Overview
Key rotation is the process of replacing an agent’s cryptographic keypair with a new one. Vestauth makes rotation simple and secure, allowing you to update keys without changing your agent’s identity (AGENT_UID).
Why Rotate Keys?
Regular key rotation is a security best practice:- Limit exposure window - If a private key is compromised, rotation limits how long it remains valid
- Compliance requirements - Many security policies require periodic key rotation
- Key lifecycle management - Replace keys that may have been exposed to insecure environments
- Proactive security - Reduce risk before a compromise occurs
Your agent identity remains constantRotating keys updates
AGENT_PUBLIC_JWK and AGENT_PRIVATE_JWK, but your AGENT_UID stays the same. Tools can continue to identify your agent across rotations.How to Rotate Keys
Using the CLI
Rotate keys with a single command:1
Generate new keypair
Vestauth generates a new Ed25519 keypair locally:
2
Register new public key
The new public key is sent to the Vestauth server:This request is signed with your current private key to prove you own the agent.
3
Update .env file
The new keys are saved to your
.env file:4
Verify rotation
Test that rotation succeeded:
Custom Hostname
Rotate keys on a self-hosted Vestauth server:Rotation Implementation
The rotation logic is implemented in/src/lib/helpers/agentRotate.js:
Programmatic Rotation
Rotate keys from code:Zero-Downtime Rotation
Vestauth servers support multi-key discovery, allowing tools to accept both old and new keys during rotation:1
Agent rotates keys
Run
vestauth agent rotate2
Server publishes both keys
The
.well-known endpoint temporarily returns both the old and new public keys:3
Tools accept either key
During the transition period, tools can verify signatures from either key based on the
keyid in the Signature-Input header.4
Old key expires
After a grace period, the old key is removed from the discovery endpoint.
Grace periodThe exact duration depends on your server configuration, but typically allows 24-48 hours for in-flight requests to complete.
Rotation Best Practices
Regular Schedule
Establish a rotation schedule based on your security requirements:Before Exposure
Rotate immediately if:- A developer leaves your team
- You suspect key compromise
- Your
.envfile was committed to version control - Keys were shared in plaintext (email, Slack, etc.)
After Exposure
If keys are compromised:1
Rotate immediately
2
Verify rotation succeeded
3
Monitor for unauthorized usage
Check tool audit logs for requests signed with the old key after rotation.
4
Revoke old key (if server supports it)
Contact your Vestauth server administrator to immediately revoke the compromised key.
Backup Keys
Automated Rotation
For production agents, automate rotation:Troubleshooting
Rotation fails with “Invalid signature”
Ensure you’re using the current private key:Old key still accepted after rotation
This is normal during the grace period. Tools accept both keys temporarily to prevent downtime.Can’t authenticate after rotation
Verify your.env file was updated:
CLI Reference
vestauth agent rotate
Rotate agent keys and update .env file.
Options:
--uid <id>- OverrideAGENT_UIDfrom environment--private-jwk <jwk>- OverrideAGENT_PRIVATE_JWKfrom environment--hostname <url>- Use custom Vestauth server (default:api.vestauth.com)--tag <tag>- Override signature tag (default:web-bot-auth)--nonce <value>- Provide custom nonce value
Next Steps
Building Tools
Build tools that handle multi-key verification
Security Model
Understand key lifecycle security