Skip to content
Tutorials Center
My learning

Topics

Lesson 7 of 36 ยท Concepts and Setup

Initializing and Unsealing Vault

Follow the first-run workflow of a real Vault: vault operator init, distributing key shares, unsealing, using and then revoking the initial root token.

A freshly installed production Vault is uninitialized: it has storage but no keys. Initialization creates the root key, the encryption key, the unseal key shares and one initial root token. It happens once per cluster. This lesson walks through the complete first-run sequence and the security habits that go with it.

This is read-only: no Vault server is available here. I describe the commands and show the shape of their output but never invent real keys or tokens. The runnable examples model the state machine and check a run book.

The three states

State How to tell What works
Uninitialized vault status shows Initialized false Only vault operator init
Initialized, sealed Initialized true, Sealed true Unseal and status calls
Unsealed Sealed false Everything your token allows
stateDiagram-v2
    [*] --> Uninitialized
    Uninitialized --> Sealed: operator init
    Sealed --> Unsealed: threshold shares provided
    Unsealed --> Sealed: operator seal / restart

A restart returns an initialized Vault to the sealed state, not to uninitialized.

Step 1: initialize

Start the server with a config file (see The Vault Configuration File), set VAULT_ADDR, and run:

Terminal
vault operator init -key-shares=5 -key-threshold=3

Vault prints five unseal key shares and the initial root token, exactly once. They are not stored anywhere recoverable. With auto-unseal the output shows recovery keys instead.

You can encrypt each share to a person's PGP public key at init time (-pgp-keys) so nobody sees raw shares, and format the output as JSON with -format=json for automation. Treat the output like nuclear launch codes: hand each share to a different custodian and never email the full set in one message.

Step 2: unseal

Terminal
vault operator unseal   # share 1
vault operator unseal   # share 2
vault operator unseal   # share 3 -> Sealed false

In a cluster, every node must be unsealed (or auto-unsealed); a standby that is sealed cannot take over leadership.

Step 3: log in with the root token, then stop using it

Terminal
vault login            # paste the initial root token

The root token has unlimited power and never expires. Use it only for initial setup: enable an auth method, write admin policies, create an admin identity. Then revoke it:

Terminal
vault token revoke -self

If you ever need a root token again, generate one with vault operator generate-root, which requires the unseal (or recovery) key threshold, and revoke it right after use. This "break glass" ceremony is the safe model.

A run book checker

This stand-in validates a list of first-run steps against the required order and common safety rules.

Python Validate a first-run run book

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Enabling an audit device early matters: until one is enabled, requests are not logged, and once one is enabled Vault will not serve requests it cannot write to the log.

An unseal progress model

Python Model unseal progress with distinct shares

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Submitting the same share twice does not count twice, which is why the progress stays at 2 after A, A, X, C: three different valid shares are required.

Safe handling checklist

  • Distribute shares to distinct people, ideally encrypted with PGP keys.
  • Store at least the threshold in separate secure locations; test the recovery procedure.
  • Enable audit logging before you create real secrets.
  • Revoke the initial root token after bootstrapping; generate a new one only with the ceremony.
  • Rekey (vault operator rekey) when custodians change, to issue a fresh set of shares.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. When is the initial root token displayed?

    Init prints the shares and root token once; they cannot be retrieved later.
  2. 2. What happens to a cluster node after a restart without auto-unseal?

    Restarts return a node to the sealed state.
  3. 3. What should you do with the initial root token after setup?

    Root tokens never expire and have unlimited power. Revoke it and use generate-root for break-glass cases.
  4. 4. What does vault operator rekey do?

    Rekeying generates new shares, useful when custodians leave.

Summary

  • A new Vault is uninitialized; vault operator init creates keys and an initial root token once.
  • Distribute shares carefully; unsealing needs the threshold of different shares on every node.
  • Use the root token only to bootstrap, then revoke it; use generate-root for emergencies.
  • Enable an audit device early.
  • Rekey when custodians change.

Next: The Vault HTTP API and CLI