Skip to main content
Rotating gossip encryption keys in your Consul cluster helps maintain strong security posture. In this tutorial, we’ll walk through:
  1. Reviewing the current configuration
  2. Generating a new encryption key
  3. Distributing the key across the cluster
  4. Promoting the new key to primary
  5. Removing the old key

1. Review Current Configuration

Inspect your existing gossip encryption key in consul.d/config.hcl:
Before you begin, back up your Consul configuration and data directory. This ensures you can recover quickly if something goes wrong.

2. Generate a New Gossip Encryption Key

Run the following command on any Consul server or client to create a fresh base64-encoded key:

3. Distribute the New Key Across the Cluster

Install the newly generated key into the cluster keyring:
You should see:

3.1. Verify Key Distribution

On another node, list installed keys:
Expected output:

4. Promote the New Key to Primary

Switch the cluster’s primary gossip encryption key:
You’ll see:
Confirm the change:
Should display the new key first under both WAN and LAN segments.

5. Remove the Old Encryption Key

Once every node is using the new key, remove the old one:
Output:
Verify only the new key remains:
Do not remove the old key until all nodes report the new key as primary. Premature removal can lead to cluster partitions and service disruptions.

Command Reference

Watch Video

Practice Lab