WireGuard Key Basics
Authentication in Mullvad is based on WireGuard public-key cryptography:- Each device generates a private key (stored locally, never transmitted)
- The corresponding public key is registered with your account
- The VPN server authenticates devices using their public keys
- No passwords or traditional credentials are used
WireGuard keys provide both authentication and encryption. Your private key never leaves your device.
Key Generation
Keys are automatically generated when you log in to an account.Login Initiates Key Generation
When you run
mullvad account login, the daemon:- Generates a new WireGuard keypair (ed25519)
- Keeps the private key locally in settings
- Sends the public key to Mullvad’s API
- Creates a device entry associated with the public key
Key Storage
Private keys are stored in:
- Linux:
/etc/mullvad-vpn/settings.json - macOS:
/Library/Preferences/Mullvad VPN/settings.json - Windows:
%LOCALAPPDATA%\Mullvad VPN\settings.json
Viewing Your Public Key
Check your current WireGuard public key and creation date.GetWireguardKey RPC returns:
key: Base64-encoded public keycreated: Timestamp when the key was generated
Automatic Key Rotation
Mullvad automatically rotates WireGuard keys for enhanced security.Why Rotate Keys?
Key rotation provides:- Forward secrecy: Compromised old keys can’t decrypt past traffic
- Reduced key exposure: Limits the time window a key is active
- Security best practice: Regular rotation minimizes cryptographic key reuse
Default Rotation Interval
By default, keys rotate every 30 days (720 hours).How Automatic Rotation Works
Rotation Timer Starts
When connected, the daemon calculates time until next rotation:If the key is older than the interval, rotation happens immediately.
Rotation is Triggered
When the timer expires, the daemon:
- Generates a new WireGuard keypair
- Uploads the new public key via API (
PUT /api/v1/accounts/devices/{id}/pubkey) - Receives new tunnel addresses (IPv4 and IPv6)
- Updates local settings with the new private key
- Reconnects the tunnel with new credentials
Rotation is seamless. You’ll experience a brief reconnection (typically under 5 seconds) but no service interruption.
Configuring Rotation Interval
Customize how often WireGuard keys rotate.Set Custom Interval
Specify the interval in hours (between 24 and 720):- 24 hours (1 day): Maximum security, frequent rotation
- 168 hours (7 days): Weekly rotation
- 360 hours (15 days): Bi-weekly rotation
- 720 hours (30 days): Default, monthly rotation
Reset to Default
Reset to the default 30-day interval:Rotation Interval Limits
The rotation interval must be between 24 and 720 hours:Manual Key Rotation
Force an immediate key rotation without waiting for the automatic interval.When to Manually Rotate
Consider manual rotation if:- You suspect your private key was compromised
- Moving to a new device and want fresh credentials
- Testing key rotation functionality
- Troubleshooting connection issues
Key Rotation Behavior When Disconnected
Key rotation timing depends on connection state:While Connected
Rotation happens automatically based on the timer:While Disconnected
The daemon doesn’t actively rotate keys when disconnected. However:- On next connection, it checks if rotation is overdue
- If
key_age > rotation_interval, rotation happens immediately - This ensures keys don’t become stale during disconnection periods
On Daemon Restart
When the daemon starts:- Loads the existing key and creation timestamp from settings
- Calculates if rotation is overdue
- If connected and overdue, initiates rotation immediately
- Otherwise, schedules the next rotation
Key Replacement API
The key rotation process uses the Device API’s public key replacement endpoint.Replace Public Key
Endpoint:PUT /api/v1/accounts/devices/{device_id}/pubkey
Request Body:
The API returns new tunnel addresses (IPv4/IPv6) which may differ from the previous ones. The daemon updates its configuration automatically.
Security Considerations
Private Key Protection
Your WireGuard private key is security-critical:- Never share your private key or settings file
- Protect settings file permissions (should be root/admin only)
- Rotate immediately if you suspect key compromise
- Logout properly from devices you no longer use (deletes keys)
Key Compromise Scenarios
If your private key is compromised:Multiple Devices and Keys
Each device has independent keys:- Device A’s key rotation doesn’t affect Device B
- Keys are device-specific, not account-wide
- Removing a device invalidates only that device’s keys
Troubleshooting
Key Rotation Fails
Problem: Key rotation initiated but connection fails. Possible Causes:- API connectivity issues
- Account expired
- Device limit reached (can’t update device)
- Check account status:
mullvad account get - Verify connectivity to Mullvad API
- Check logs for specific error messages
- Try manual rotation:
mullvad tunnel set rotate-key
Connection Drops During Rotation
Problem: VPN disconnects briefly during automatic rotation. Expected Behavior: Brief disconnection (under 5 seconds) is normal during rotation. If Prolonged:- Check if reconnection succeeds automatically
- Manually reconnect:
mullvad connect - Review rotation interval - more frequent rotation = more disruptions
Old Key Still Active
Problem: Old public key still showing after rotation. Solution:- Refresh device info: The daemon updates automatically
- Verify with:
mullvad tunnel get(check “Created” timestamp) - Manually trigger:
mullvad tunnel set rotate-key
Can’t Set Rotation Interval
Problem: Error when setting custom rotation interval. Common Issues:- Value outside 24-720 hour range
- Non-integer value provided
- Using minutes/days instead of hours
Related Topics
- Account Management - Account creation and login
- Device Management - Managing multiple devices
CLI Reference
| Command | Description |
|---|---|
mullvad tunnel get | Display current tunnel options and public key |
mullvad tunnel set rotation-interval <HOURS> | Set automatic key rotation interval (24-720) |
mullvad tunnel set rotation-interval any | Reset to default rotation interval (720 hours) |
mullvad tunnel set rotate-key | Manually rotate WireGuard key immediately |
gRPC Service Reference
| RPC | Request | Response | Description |
|---|---|---|---|
SetWireguardRotationInterval | Duration | Empty | Set automatic rotation interval |
ResetWireguardRotationInterval | Empty | Empty | Reset to default interval |
RotateWireguardKey | Empty | Empty | Force immediate key rotation |
GetWireguardKey | Empty | PublicKey | Get current public key and creation time |
PublicKey Message
TunnelOptions Message
Key Rotation Timeline Example
Here’s how automatic rotation works over time:Each rotation generates fresh cryptographic material, ensuring your connection uses modern, uncompromised keys.