Secrets Management

Vault Seal, Unseal, and Rekey: Complete Security Operations Guide

Master HashiCorp Vault unsealing, sealing, and rekeying operations. Step-by-step commands for security management, auto-unseal configuration, and key rotation best practices.

By InventiveHQ Team

Vault's seal/unseal mechanism is a fundamental security feature that protects secrets even when storage is compromised. Understanding these operations is essential for Vault administrators. This guide covers unsealing, sealing, rekeying, and auto-unseal configuration. For broader setup and administration, see the complete HashiCorp Vault guide.

Understanding Vault Sealing

Vault starts sealed. With Shamir sealing, operators must submit enough shares after a restart; with configured auto-unseal, Vault can unseal on startup through its seal service. While sealed, Vault cannot decrypt stored data to serve requests:

  • Vault cannot serve stored secrets to clients
  • Normal secret read and write operations are unavailable
  • Status and unseal operations remain available
  • Even with access to storage, data cannot be decrypted
┌─────────────────────────────────────────────────────────┐
│                    SEALED STATE                          │
│  ┌─────────────┐    ┌──────────────┐    ┌────────────┐ │
│  │   Storage   │    │  Encrypted   │    │  No Access │ │
│  │   (Data)    │───▶│  Key Chain   │───▶│  to Secrets│ │
│  └─────────────┘    └──────────────┘    └────────────┘ │
└─────────────────────────────────────────────────────────┘
                           │
                    Unseal Keys
                           │
                           ▼
┌─────────────────────────────────────────────────────────┐
│                   UNSEALED STATE                         │
│  ┌─────────────┐    ┌──────────────┐    ┌────────────┐ │
│  │   Storage   │    │  Decrypted   │    │   Secrets  │ │
│  │   (Data)    │───▶│  Key Chain   │───▶│ Accessible │ │
│  └─────────────┘    └──────────────┘    └────────────┘ │
└─────────────────────────────────────────────────────────┘

Shamir's Secret Sharing

Vault encrypts stored data with keys in its keyring. Its root key protects the keyring, and the unseal key protects the root key. With Shamir sealing, Vault splits the unseal key into shares. During initialization, you specify:

  • Key shares: Total number of unseal keys generated
  • Key threshold: Minimum keys needed to unseal

Common configurations:

  • 3-of-5: Five keys distributed to different people, any three can unseal
  • 2-of-3: Three keys, any two can unseal (smaller teams)
  • 1-of-1: Single key (development only, not recommended for production)

Checking Vault Status

Before any seal operation, check Vault's current status:

vault status

Example output when sealed:

Key                Value
---                -----
Seal Type          shamir
Initialized        true
Sealed             true
Total Shares       5
Threshold          3
Unseal Progress    0/3
Unseal Nonce       n/a
Storage Type       raft
HA Enabled         true

Key fields:

  • Sealed: true means Vault is sealed
  • Total Shares: Number of unseal keys that exist
  • Threshold: Keys needed to unseal
  • Unseal Progress: How many keys have been submitted

Unsealing Vault

Step-by-Step Unseal Process

This manual process applies to Shamir sealing. For auto-unseal, check the configured seal service and node startup status instead.

# Check current status
vault status

# Begin unsealing - enter first key
vault operator unseal
# Prompt: Unseal Key (will be hidden):
# Enter first unseal key

# Check progress
vault status
# Should show: Unseal Progress 1/3

# Continue with second key
vault operator unseal
# Enter second unseal key

# Final key to reach threshold
vault operator unseal
# Enter third unseal key

# Verify unsealed
vault status
# Should show: Sealed false

Non-Interactive Unseal

For automation (use with caution):

# Provide key directly (appears in process list!)
vault operator unseal "$UNSEAL_KEY_1"

# For interactive entry, omit the key argument and enter it at the prompt
vault operator unseal

Unseal Multiple Nodes (HA Cluster)

With Shamir sealing in an HA cluster, submit the required threshold of distinct unseal shares to each node separately. Point each request at the intended node rather than a load balancer:

# Submit one share to the first node; repeat with other shares until its threshold is met
VAULT_ADDR=https://vault-1.example.com:8200 vault operator unseal

# Repeat the threshold process for each standby node
VAULT_ADDR=https://vault-2.example.com:8200 vault operator unseal
VAULT_ADDR=https://vault-3.example.com:8200 vault operator unseal

With auto-unseal, configure the seal service on each node and check that the nodes unseal through it on startup. Recovery shares authorize certain privileged operations; they cannot replace the seal service if it is unavailable. See HashiCorp's seal and unseal documentation.

Manual Sealing

When to Seal Vault

Seal Vault manually in these scenarios:

  1. Security Incidents: Seal as part of an incident response plan when stopping new access to Vault helps containment
  2. Planned Testing: Verify your seal and unseal procedure in a controlled window
  3. Specific Compliance Requirements: Demonstrate seal capability if your audit requires it
  4. Emergency Response: Part of incident response procedures
  5. Testing: Verify unseal procedures work correctly

Sealing Commands

# Must be authenticated first
vault login

# Seal Vault (requires sudo capability in policy)
vault operator seal

# Verify sealed
vault status

Warning: Sealing stops applications from making new secret requests to that Vault node, but it does not revoke secrets already fetched. Plan seal operations carefully, notify stakeholders, and rotate affected credentials when needed.

Emergency Seal

If your incident response plan calls for sealing after a suspected breach:

# Stop new access to secrets on this Vault node
vault operator seal

# Continue containment, investigate, and rotate affected credentials
# Restore access according to the incident response plan

Rekeying Vault

Rekeying replaces the shares for the selected target: Shamir unseal shares or auto-unseal recovery shares. Previously issued shares for that target become invalid when the rekey completes.

When to Rekey

  • Personnel Changes: When employees holding unseal or recovery shares leave
  • Key Compromise: If an unseal or recovery share might be compromised
  • Threshold Changes: Changing from 3-of-5 to 4-of-7, etc.
  • Scheduled Rotation: Follow a cadence based on your threat model and applicable requirements
  • Security Incidents: After investigating potential breaches

Rekey Process

Step 1: Initialize Rekeying

For Shamir unseal shares, start a rekey with verification enabled. The share count and threshold below are examples; choose values for your custody plan:

vault operator rekey -init -key-shares=5 -key-threshold=3 -verify

For auto-unseal recovery shares, target recovery explicitly:

vault operator rekey -target=recovery -init -key-shares=5 -key-threshold=3 -verify

Use the rekey nonce returned by your own initialization. See the HashiCorp rekey command reference for the available flags.

Step 2: Submit Existing Unseal Keys

For Shamir sealing, each key holder submits a current unseal share. For auto-unseal, submit current recovery shares instead. Repeat until the existing threshold is met:

# Shamir: enter one current unseal share when prompted
vault operator rekey -nonce="<rekey-nonce>"

# Auto-unseal: enter one current recovery share when prompted
vault operator rekey -target=recovery -nonce="<rekey-nonce>"

Step 3: Receive New Keys

When the current threshold is met, Vault returns new shares for the selected target. Deliver each share securely to its intended holder and confirm receipt through your custody process. Because this example enabled -verify, have holders submit distinct new shares to Vault's rekey verification phase using the verification nonce returned by the operation. Repeat until the new threshold is met:

# Shamir: enter one new unseal share when prompted
vault operator rekey -verify -nonce="<verification-nonce>"

# Auto-unseal: enter one new recovery share when prompted
vault operator rekey -target=recovery -verify -nonce="<verification-nonce>"

Vault completes a rekey with verification enabled after the verification threshold is met. vault status shows seal state and share thresholds; it does not prove that holders received, stored, or verified their new shares. Record the completed verification and custody acknowledgments separately.

Advertisement

Rekey with PGP Encryption

For Shamir sealing, encrypt new unseal shares to the recipients' PGP public keys:

# Initialize rekey with PGP keys
vault operator rekey -init \
  -key-shares=5 \
  -key-threshold=3 \
  -pgp-keys="keybase:user1,keybase:user2,keybase:user3,keybase:user4,keybase:user5"

For auto-unseal recovery shares, add -target=recovery to the initialization command and use the recovery target when submitting current shares. Each generated share is encrypted to its corresponding PGP public key; holders still need to confirm that they can decrypt and store their shares securely.

Cancel Rekey Operation

If needed, cancel an in-progress Shamir rekey. Add -target=recovery when canceling a recovery-share rekey:

vault operator rekey -cancel

Auto-Unseal Configuration

Auto-unseal uses external key management systems to automatically unseal Vault on startup.

AWS KMS Auto-Unseal

Vault needs AWS credentials on each node, such as an IAM role or another method supported by the AWS SDK. The principal must be allowed to use the KMS key; see HashiCorp's AWS KMS seal configuration.

# vault.hcl configuration
seal "awskms" {
  region     = "us-east-1"
  kms_key_id = "alias/vault-unseal-key"
}

KMS key permissions needed by the Vault principal:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "kms:Encrypt",
        "kms:Decrypt",
        "kms:DescribeKey"
      ],
      "Resource": "arn:aws:kms:us-east-1:*:key/your-key-id"
    }
  ]
}

Azure Key Vault Auto-Unseal

This example assumes Azure Managed Service Identity (MSI) is enabled on each VM hosting Vault and that the identity can use the named Key Vault key. Without MSI, supply client_id and client_secret through supported configuration or environment variables. Keep credentials out of shared example files; see HashiCorp's Azure Key Vault seal configuration for authentication and key access requirements.

seal "azurekeyvault" {
  tenant_id      = "your-tenant-id"
  vault_name     = "vault-unseal"
  key_name       = "vault-key"
}

GCP Cloud KMS Auto-Unseal

Vault needs Google application credentials on each node, such as an attached service account or credentials supplied through a supported method. Grant that identity encrypt, decrypt, and key metadata access on the crypto key; see HashiCorp's GCP Cloud KMS seal configuration.

seal "gcpckms" {
  project     = "your-project"
  region      = "global"
  key_ring    = "vault-keyring"
  crypto_key  = "vault-key"
}

Migration to Auto-Unseal

Migrating from Shamir to auto-unseal requires a planned seal migration, a backup, and access to both the existing shares and the new seal service. The sequence depends on your Vault deployment and storage backend. For an HA cluster, coordinate nodes one at a time as directed by the HashiCorp seal migration procedure. With integrated Raft storage, keep a quorum online and follow the storage-specific sequencing in that procedure. The following command illustrates how an existing Shamir share is submitted during a migration; it is not a complete cluster runbook:

# Submit a current Shamir share when the migration procedure calls for it
vault operator unseal -migrate

After migration, the former Shamir shares serve as recovery keys for privileged operations such as:

  • Root token generation
  • Rekeying recovery keys
  • Disabling auto-unseal

Security Best Practices

1. Distribute Keys Properly

Key Distribution Strategy:
- Key 1: CTO (Executive)
- Key 2: Security Team Lead
- Key 3: Infrastructure Manager
- Key 4: On-Call Engineer (rotating)
- Key 5: Secure Offline Storage (safe deposit box)

2. Store Keys Securely

  • Use hardware security modules (HSM) or secure enclaves
  • Keep unseal and recovery keys out of version control
  • Consider key management services for key storage
  • Maintain encrypted backups in geographically separate locations

3. Document Procedures

## Unseal Procedure Runbook

1. Verify incident requiring unseal
2. Contact key holders (minimum 3)
3. Each key holder authenticates identity
4. Key holders submit keys via secure channel
5. Verify Vault is unsealed
6. Document in incident log

4. Enable Audit Logging

# Enable an audit device for auditable API operations
vault audit enable file file_path=/var/log/vault/audit.log

Vault exempts sys/seal and sys/unseal from audit logging. Monitor seal state through status checks and use server logs or your infrastructure monitoring to investigate restarts and seal events; do not rely on the audit file for a complete record of seal and unseal operations.

5. Backup Before Rekeying

# Create Raft snapshot before rekey
vault operator raft snapshot save pre-rekey-backup.snap

# Inspect the saved snapshot, then store it securely
vault operator raft snapshot inspect pre-rekey-backup.snap

6. Test Recovery Procedures

Set recovery test intervals according to your threat model and operational requirements. Test your ability to:

  • Unseal Vault after a planned restart when using Shamir sealing, or verify auto-unseal on startup
  • Rekey with new key distribution
  • Recover from disaster scenario

Troubleshooting

Cannot Unseal

Symptom: Keys are rejected during unseal

Causes:

  • Wrong unseal key entered
  • Keys from different Vault initialization
  • Vault was rekeyed and old keys used

Solution:

# Check the node's seal type, status, and unseal progress
vault status

Confirm that the shares belong to this cluster and are current using your securely maintained key records. vault status reports seal state and threshold, but does not show initialization or rekey timestamps.

Unseal Progress Resets

Symptom: Progress resets to 0/N

Causes:

  • Vault restarted
  • An operator reset the unseal process with vault operator unseal -reset

Solution:

  • Check whether the node restarted or an operator reset the unseal process
  • Confirm that key holders are submitting shares to the same Vault node

All Keys Lost

Symptom: Cannot reach unseal threshold

Reality: With Shamir sealing, a sealed Vault cannot be unsealed or rekeyed if fewer valid shares remain than the threshold. Check for securely stored copies of the current shares before concluding access is lost. With auto-unseal, lost recovery keys do not by themselves prevent Vault from unsealing through its configured seal service, but they are needed for certain privileged operations. Recovery keys cannot unseal Vault if that service is unavailable; a permanently lost seal key can make the cluster unrecoverable.

Prevention:

  • Distribute keys to multiple trusted parties
  • Maintain secure backups
  • Document key holder contact information
  • Consider auto-unseal for critical environments

Performance After Unseal

Symptom: Slow operations after unsealing

Possible causes: The slowdown may reflect the storage backend, network, workload, or another service dependency. Investigate the observed symptoms before assigning a cause.

Solution:

  • Compare request latency and errors with the baseline from before unsealing
  • Check Vault server logs and storage, seal-service, and network health
  • Investigate sustained degradation using the observed errors and metrics

Command Reference

CommandDescription
vault statusCheck seal status
vault operator unsealSubmit a Shamir unseal share
vault operator sealSeal Vault
vault operator rekey -initStart a Shamir unseal-share rekey
vault operator rekey -target=recovery -initStart an auto-unseal recovery-share rekey
vault operator rekeySubmit a Shamir share; add -target=recovery for recovery shares
vault operator rekey -verifySubmit a new share during verification, if enabled; add -target=recovery for recovery shares
vault operator rekey -cancelCancel a Shamir rekey; add -target=recovery for recovery shares
vault operator rekey -statusCheck Shamir rekey progress; add -target=recovery for recovery shares

Next Steps

For more security operations guides, explore our complete HashiCorp Vault series.

Frequently Asked Questions

What does it mean when Vault is sealed?

When Vault is sealed, it cannot decrypt stored secrets to serve new requests. Vault starts sealed; after a restart, a configured auto-unseal mechanism can unseal it on startup. Sealing does not revoke secrets clients already retrieved.

How do I unseal Vault?

With Shamir sealing, run 'vault operator unseal' and enter a distinct unseal share for each request until you reach the configured threshold. Each key holder should enter their share separately. With auto-unseal, Vault uses its configured seal service; recovery shares cannot replace that service.

How many unseal keys do I need?

For Shamir sealing, you need the configured threshold of distinct unseal shares, such as 3 of 5 or 2 of 3. Check the node's seal type and threshold with 'vault status'. With auto-unseal, the seal service unseals Vault; recovery shares authorize certain privileged operations.

When should I manually seal Vault?

Manually seal Vault when your incident response procedure calls for it, or when testing seal and unseal procedures in a planned window. Use 'vault operator seal'. Sealing does not revoke secrets already retrieved; contain the incident and rotate affected credentials as needed.

What is Vault rekeying and when should I do it?

Rekeying replaces Shamir unseal shares or, with auto-unseal, recovery shares. Consider rekeying when key holders leave, after suspected share compromise, or when the share threshold or custody plan changes. Use the recovery target for auto-unseal recovery shares.

How do I change the number of unseal keys?

With Shamir sealing, start with 'vault operator rekey -init -key-shares=5 -key-threshold=3' and submit the current unseal shares to the existing threshold. With auto-unseal, rekey recovery shares using 'vault operator rekey -target=recovery -init -key-shares=5 -key-threshold=3' and submit current recovery shares. Confirm custody of the new shares; 'vault status' cannot verify their receipt or distribution.

What is auto-unseal and how does it work?

Auto-unseal uses a cloud KMS (AWS, Azure, GCP) or HSM to automatically unseal Vault on startup. The seal mechanism protects Vault's root key. Configure it in the Vault config with a 'seal' stanza.

Can I unseal Vault remotely?

With Shamir sealing, key holders can set VAULT_ADDR to a Vault node and run 'vault operator unseal' from different locations, each submitting a distinct share. Auto-unseal uses the configured seal service instead.

What happens if I lose unseal keys?

With Shamir sealing, losing enough unseal key shares to fall below the threshold prevents unsealing and rekeying unless you can recover valid shares. With auto-unseal, Vault uses its configured seal service to unseal; recovery keys authorize certain privileged operations but cannot replace an unavailable seal service. Protect both key shares and the external seal mechanism.

How often should I rotate unseal keys?

Set a rekey schedule based on your threat model, key custody, and applicable requirements. Consider rekeying when key holders leave, after suspected key compromise, or when security requirements change, and document the decision and operation.

hashicorpvaultsecrets managementsecurityoperations