OpenBao

OpenBao is the open-source fork of HashiCorp Vault, run under the Linux Foundation after Vault moved to the Business Source License. It stores secrets, issues short-lived credentials on demand, encrypts data for applications, and records every access in an audit log. The bao CLI and the API work the way Vault users know them.

This guide builds a production cluster: three nodes with integrated Raft storage, TLS everywhere, auto-unseal with a key protected by each VM’s TPM, a virtual IP that follows the active node, and declarative audit logging. People log in with authentik (backed by Active Directory, with MFA) or directly against AD. Applications get database passwords that live for an hour from your Patroni PostgreSQL cluster, instead of one password in a config file forever.

What you’ll end up with:

  • OpenBao 2.7 on three Debian 13 VMs, installed from the signed release package and verified with GPG
  • Raft integrated storage: no Consul, no external database, automatic leader election
  • Auto-unseal with OpenBao’s static seal, where the key is encrypted by the VM’s TPM through systemd-creds, so a reboot needs no human and a copied disk is useless
  • keepalived, moving a VIP to whichever node is the active one
  • Audit logging declared in the config file, to a file and the journal
  • Human login through authentik with OIDC (AD users with MFA), and the AD LDAP plugin as a direct alternative, with AD groups mapped to policies
  • AppRole for machines
  • KV v2 for static secrets, and the database engine issuing dynamic PostgreSQL users on Patroni
  • Raft snapshots on a timer, Prometheus metrics, rolling upgrades and a break-glass procedure

Tested on: Debian 13 “trixie” with OpenBao 2.7.3, keepalived 2.3, PostgreSQL 17 under Patroni, and authentik 2026.8. All commands run as root unless noted.


Table of contents

  1. Architecture and concepts
  2. Placeholders
  3. Prerequisites
  4. Install OpenBao from the signed package
  5. TLS certificates
  6. The unseal key, protected by the TPM
  7. Server configuration
  8. Firewall
  9. Start, initialise and join the cluster
  10. A VIP that follows the active node
  11. Policies
  12. Login with authentik (OIDC)
  13. Login with Active Directory (LDAP plugin)
  14. Machines: AppRole
  15. Static secrets: KV v2
  16. Dynamic PostgreSQL credentials on Patroni
  17. Retiring the root token
  18. Backups: Raft snapshots
  19. Monitoring
  20. Day-2 operations and upgrades
  21. Troubleshooting
  22. Checklist

1. Architecture and concepts

                 people (UI, CLI)          applications, scripts
                        โ”‚                          โ”‚
                        โ–ผ  HTTPS :8200             โ–ผ
                VIP 10.20.0.60  bao.mydomain.local  (follows the ACTIVE node)
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ–ผ                     โ–ผ                     โ–ผ
   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ”‚ bao-01      โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ–บโ”‚ bao-02      โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ–บโ”‚ bao-03      โ”‚
   โ”‚ ACTIVE      โ”‚ Raft  โ”‚ standby     โ”‚ Raft  โ”‚ standby     โ”‚
   โ”‚ :8200 API   โ”‚ :8201 โ”‚ :8200       โ”‚ :8201 โ”‚ :8200       โ”‚
   โ”‚ TPM โ”€โ–บ seal โ”‚  TLS  โ”‚ TPM โ”€โ–บ seal โ”‚  TLS  โ”‚ TPM โ”€โ–บ seal โ”‚
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
          โ”‚ OIDC                 โ”‚ LDAPS (plugin)        โ”‚ SQL (TLS)
          โ–ผ                      โ–ผ                       โ–ผ
   auth.mydomain.local     dc01 / dc02            Patroni leader
   (authentik)             (Active Directory)     pg.mydomain.local

A few concepts the rest of the guide depends on:

  • Sealed vs. unsealed. Everything OpenBao stores is encrypted. After a start, a node is sealed: it has the data but can’t read it. Unsealing gives it the key. Auto-unseal does that without a person.
  • Active and standby. One node is active and handles all requests. The standbys replicate through Raft and forward requests they receive to the active node. If the active node fails, the remaining two elect a new one. Three nodes tolerate the loss of one.
  • Tokens and policies. Every login produces a token with a time to live and a set of policies. Policies are deny-by-default path rules. Nothing is allowed unless a policy says so.
  • Leases. Dynamic secrets (the database users in section 16) come with a lease. When it expires, OpenBao deletes the credential. A leaked password stops working on its own.

2. Placeholders

PlaceholderMeaning
bao.mydomain.local / 10.20.0.60VIP, the address clients use
bao-01, bao-02, bao-03 / 10.20.0.61โ€“.63The three nodes, interface ens192
auth.mydomain.localauthentik (my authentik High Availability guide)
dc01, dc02.mydomain.localDomain controllers, base DN DC=mydomain,DC=local
pg.mydomain.localThe Patroni leader VIP (vip-manager), PostgreSQL 5432
10.20.0.0/16Networks with clients that may use OpenBao
10.20.90.0/24Admin network (SSH)
10.20.0.112Prometheus
mydomain-ca.pemYour internal CA chain

3. Prerequisites

  • Three Debian 13 VMs on three different hypervisor hosts (anti-affinity rule), 2 vCPU, 4 GB RAM, a fast disk for Raft. Hardened as in my Debian 13 VM hardening guide. No other services on them. A secrets manager doesn’t share a box.
  • A virtual TPM on every VM (vSphere: a vTPM needs a key provider configured on vCenter; Proxmox: add a TPM state disk), and UEFI with Secure Boot. Check with ls /dev/tpmrm0 and systemd-analyze has-tpm2.
  • Swap off, or at least never used for OpenBao’s memory. The package’s unit already sets MemorySwapMax=0.
  • DNS: A and PTR for the three nodes, A for bao.mydomain.local โ†’ the VIP.
  • NTP on all nodes. Tokens, leases and TLS all depend on time.
  • For section 12: authentik. For section 13: AD with LDAPS. For section 16: the Patroni cluster from my PostgreSQL HA with Patroni and etcd guide.

4. Install OpenBao from the signed package

On every node. OpenBao publishes its releases with a checksum file that is GPG-signed and Sigstore-signed. Verify the signature first, then the package against the checksums:

apt install curl gnupg jq keepalived nftables

VER=2.7.3
BASE="https://github.com/openbao/openbao/releases/download/v${VER}"
WORK=$(mktemp -d) && cd "$WORK"

curl -fsSLO "$BASE/checksums.txt"
curl -fsSLO "$BASE/checksums.txt.gpgsig"

# OpenBao's release key; check the fingerprint against openbao.org/docs/install
curl -fsSL https://openbao.org/assets/openbao-gpg-pub-20240618.asc | gpg --import
gpg --fingerprint 66D15FDD87287219C8E15478D200CD702853E6D0
gpg --verify checksums.txt.gpgsig checksums.txt     # must say "Good signature"

# the Debian package for amd64, as listed in the signed checksums
DEB=$(awk '/linux_amd64\.deb$/ {print $2}' checksums.txt)
echo "$DEB"
curl -fsSLO "$BASE/$DEB"
sha256sum --ignore-missing --check checksums.txt    # must say "OK"

apt install "./$DEB"
bao versionCode language: PHP (php)

If you’d rather verify with Sigstore: cosign verify-blob --bundle checksums.txt.sigstore.json with the issuer and identity from the install page.

The package:

WhatWhere
Binary/usr/bin/bao
Unitopenbao.service: runs as user openbao, NoNewPrivileges, ProtectSystem=full, PrivateTmp, MemorySwapMax=0
Configuration/etc/openbao/openbao.hcl, environment in /etc/openbao/openbao.env
Data/opt/openbao/data
TLS/opt/openbao/tls/, where the package puts a self-signed certificate on first install. We replace it in section 5.

A package installed outside an apt repository doesn’t update by itself. Put OpenBao releases on your watch list (GitHub releases feed) and follow section 20.


5. TLS certificates

Each node gets its own certificate from your CA. The SANs must contain the node’s name and IP, and the VIP name and address, because clients reach the active node through both:

# per node, on your CA machine (see my certificate management guide)
N=bao-01; IP=10.20.0.61
openssl req -new -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \
    -keyout $N.key -out $N.csr -subj "/CN=$N.mydomain.local" \
    -addext "subjectAltName=DNS:$N.mydomain.local,DNS:bao.mydomain.local,IP:$IP,IP:10.20.0.60,IP:127.0.0.1" \
    -addext "extendedKeyUsage=serverAuth,clientAuth"Code language: PHP (php)

127.0.0.1 in the SANs lets the local health check (section 10) verify the certificate. clientAuth is there because the nodes connect to each other when they join.

On each node, with the signed certificate (followed by the intermediate) and the key:

install -m 0644 -o openbao -g openbao bao-01.crt       /opt/openbao/tls/tls.crt
install -m 0600 -o openbao -g openbao bao-01.key       /opt/openbao/tls/tls.key
install -m 0644 -o openbao -g openbao mydomain-ca.pem  /opt/openbao/tls/ca.pem
install -m 0644 mydomain-ca.pem /usr/local/share/ca-certificates/mydomain-ca.crt
update-ca-certificates

The listener reloads renewed certificates by itself (tls_auto_reload, section 7). Renewal is a file copy, not a restart.


6. The unseal key, protected by the TPM

6.1 Choosing a seal

SealHow it unsealsFit
Shamir (default)3 of 5 people enter key shares after every restart of every nodeStrongest separation, but a patch night needs three key holders awake
TransitAnother OpenBao cluster holds the keyGood if you already have a second cluster
PKCS#11 (plugin)An HSMBest, if you have an HSM
StaticA 32-byte key, read from a file at startSimple, and only as strong as the protection of that file

This guide uses the static seal, and protects the file with the TPM. systemd-creds encrypts the key with a key that’s sealed in this VM’s TPM. systemd decrypts it only when it starts openbao.service, into a memory-only directory that only the service can read. On disk there’s only ciphertext. A copied disk or a stolen backup of the VM is useless without that VM’s TPM.

What it doesn’t protect against: root on the running node. But root on the running node can read OpenBao’s memory anyway. Shamir doesn’t help there either, once the node is unsealed.

6.2 Create the key once and encrypt it on every node

On bao-01, create the key in a memory-only directory:

install -d -m 0700 /run/bao-seal
openssl rand -out /run/bao-seal/unseal.key 32

Store a copy offline: in your password manager as base64 (base64 -w0 /run/bao-seal/unseal.key), or printed and in a safe. If all three VMs lose their TPM (re-created VMs, a broken key provider), this copy is the only way to unseal the data again.

Copy it to bao-02 and bao-03, over SSH into /run/bao-seal/ there, and on each node encrypt it with that node’s TPM:

install -d -m 0700 /etc/credstore.encrypted
systemd-creds encrypt --with-key=tpm2 --name=unseal-key \
    /run/bao-seal/unseal.key /etc/credstore.encrypted/openbao-unseal-key.cred
shred -u /run/bao-seal/unseal.key
systemd-creds decrypt --name=unseal-key /etc/credstore.encrypted/openbao-unseal-key.cred - | wc -c   # 32Code language: PHP (php)

6.3 Hand it to the service

mkdir -p /etc/systemd/system/openbao.service.d
cat > /etc/systemd/system/openbao.service.d/10-unseal-key.conf <<'EOF'
[Service]
LoadCredentialEncrypted=unseal-key:/etc/credstore.encrypted/openbao-unseal-key.cred
EOF
systemctl daemon-reloadCode language: JavaScript (javascript)

At start, systemd decrypts the key to /run/credentials/openbao.service/unseal-key, readable only by the service, and removes it when the service stops. That’s the path the seal configuration reads.


7. Server configuration

/etc/openbao/openbao.hcl on bao-01. On the other nodes, change node_id, api_addr, cluster_addr, the listener’s cluster_address and the retry_join targets:

# /etc/openbao/openbao.hcl - bao-01

ui           = true
cluster_name = "mydomain-bao"

api_addr     = "https://bao-01.mydomain.local:8200"
cluster_addr = "https://bao-01.mydomain.local:8201"

default_lease_ttl = "1h"
max_lease_ttl     = "768h"

listener "tcp" {
  address         = "0.0.0.0:8200"
  cluster_address = "10.20.0.61:8201"

  tls_cert_file    = "/opt/openbao/tls/tls.crt"
  tls_key_file     = "/opt/openbao/tls/tls.key"
  tls_min_version  = "tls12"
  tls_auto_reload  = true

  telemetry {
    unauthenticated_metrics_access = false
  }
}

storage "raft" {
  path                   = "/opt/openbao/data"
  node_id                = "bao-01"
  performance_multiplier = 1

  retry_join {
    leader_api_addr       = "https://bao-02.mydomain.local:8200"
    leader_tls_servername = "bao-02.mydomain.local"
    leader_ca_cert_file   = "/opt/openbao/tls/ca.pem"
  }
  retry_join {
    leader_api_addr       = "https://bao-03.mydomain.local:8200"
    leader_tls_servername = "bao-03.mydomain.local"
    leader_ca_cert_file   = "/opt/openbao/tls/ca.pem"
  }
}

seal "static" {
  current_key_id = "2026-11"
  current_key    = "file:///run/credentials/openbao.service/unseal-key"
}

# Audit devices are declared here, not created through the API
audit "file" "file" {
  description = "Audit log on disk"
  options {
    file_path = "/var/log/openbao/audit.log"
    mode      = "0600"
  }
}
audit "syslog" "journal" {
  description = "Second audit device, so a full disk doesn't stop OpenBao"
  options {
    tag      = "openbao-audit"
    facility = "AUTH"
  }
}

# External plugins (LDAP, section 13): root-owned directory the service can't write
plugin_directory = "/usr/local/libexec/openbao-plugins"

telemetry {
  prometheus_retention_time = "24h"
  disable_hostname          = true
}Code language: PHP (php)
install -d -m 0750 -o openbao -g openbao /var/log/openbao
install -d -m 0755 -o root -g root /usr/local/libexec/openbao-plugins
chown root:openbao /etc/openbao/openbao.hcl && chmod 0640 /etc/openbao/openbao.hclCode language: JavaScript (javascript)

What matters here:

  • api_addr / cluster_addr are the node’s own names. Standbys tell clients and each other where the active node is through these addresses.
  • performance_multiplier = 1 is Raft’s fastest timing, which the documentation recommends for production on a good network.
  • retry_join lists the other two nodes, with certificate verification against your CA. A new or restarted node finds the cluster by itself.
  • Two audit devices. OpenBao refuses requests it can’t audit. With only a file, a full /var would stop the whole service. In OpenBao, enabling audit devices through the API is off by default for security reasons. Declaring them here also means they’re active from the very first request.
  • The plugin directory belongs to root and isn’t writable by openbao. A compromised service can’t swap plugin binaries.

Log rotation for the audit file. OpenBao reopens it on SIGHUP, which is what the unit’s reload sends:

cat > /etc/logrotate.d/openbao <<'EOF'
/var/log/openbao/audit.log {
    daily
    rotate 30
    compress
    delaycompress
    missingok
    notifempty
    postrotate
        systemctl reload openbao >/dev/null 2>&1 || true
    endscript
}
EOFCode language: JavaScript (javascript)

Forward the audit log to your SIEM. It records every request with HMAC-hashed secrets, so you can see who read what, without the values themselves.


8. Firewall

/etc/nftables.conf, in the style of my nftables on Debian 13 guide. SELF is the only line that differs per node:

#!/usr/sbin/nft -f
define SELF = 10.20.0.61            # per node

destroy table inet filter

table inet filter {
    set bao_nodes  { type ipv4_addr; elements = { 10.20.0.61, 10.20.0.62, 10.20.0.63 } }
    set clients_v4 { type ipv4_addr; flags interval; elements = { 10.20.0.0/16 } }
    set admin_v4   { type ipv4_addr; flags interval; elements = { 10.20.90.0/24 } }

    chain input {
        type filter hook input priority filter; policy drop;

        ct state vmap { established : accept, related : accept, invalid : drop }
        iifname "lo" accept

        icmp type { destination-unreachable, time-exceeded, parameter-problem } accept
        icmp type echo-request limit rate 10/second accept
        icmpv6 type { destination-unreachable, packet-too-big, time-exceeded, parameter-problem } accept
        icmpv6 type { nd-router-advert, nd-neighbor-solicit, nd-neighbor-advert } ip6 hoplimit 255 accept

        # API and UI (includes metrics, which need a token)
        tcp dport 8200 ip saddr @clients_v4 accept

        # Raft and request forwarding: only between the nodes
        tcp dport 8201 ip saddr @bao_nodes accept

        # keepalived: unicast VRRP from the other nodes
        ip protocol 112 ip saddr @bao_nodes ip daddr $SELF accept

        tcp dport 22 ip saddr @admin_v4 ct state new accept

        limit rate 10/minute burst 20 packets log prefix "nft input drop: " level info
    }
    chain forward { type filter hook forward priority filter; policy drop; }
    chain output  { type filter hook output priority filter; policy accept; }
}Code language: PHP (php)
nft -c -f /etc/nftables.conf && systemctl enable --now nftables && systemctl reload nftables

Port 8201 is the crown jewel. It carries Raft replication and forwarded requests. Only the three nodes may reach it.


9. Start, initialise and join the cluster

Start all three:

systemctl enable --now openbao
journalctl -u openbao -f

The nodes start uninitialised and keep trying to join each other, which is expected until one of them is initialised.

Initialise once, on bao-01. With an auto-unseal seal, OpenBao produces recovery keys instead of unseal keys. They don’t unseal anything, but you need them for operations such as generating a new root token:

export BAO_ADDR=https://bao-01.mydomain.local:8200
export BAO_CACERT=/opt/openbao/tls/ca.pem

bao operator init -recovery-shares=5 -recovery-threshold=3Code language: JavaScript (javascript)

The output contains five recovery keys and the initial root token. Hand the recovery keys to five different people (password manager entries they own, or sealed envelopes), three of whom must cooperate. The root token is for the next hour only (section 17).

Seconds later, bao-02 and bao-03 join through retry_join and unseal themselves with their own TPM-protected key:

bao status                                  # Sealed false, HA Mode active
bao login                                   # with the root token, for now
bao operator raft list-peers
bao operator raft autopilot stateCode language: PHP (php)
Node      Address                      State       Voter
----      -------                      -----       -----
bao-01    bao-01.mydomain.local:8201   leader      true
bao-02    bao-02.mydomain.local:8201   follower    true
bao-03    bao-03.mydomain.local:8201   follower    trueCode language: CSS (css)

Test the auto-unseal now, before there’s anything in it: systemctl restart openbao on a standby, then bao status on that node. It must come back Sealed false without you doing anything.

Declarative alternative: OpenBao can also initialise itself from initialize blocks in the configuration (self-init), with auto-unseal. Then no root token ever leaves the server, because it’s revoked after the initial requests. That’s useful for fully automated builds. Doing it by hand, as above, is easier to follow the first time.


10. A VIP that follows the active node

Standbys forward requests, so any node works for clients. A VIP on the active node saves the extra hop and gives clients one stable name. keepalived gets a bonus in priority on the node whose health endpoint says “active”:

/usr/local/libexec/keepalived/check_bao_active.sh:

#!/bin/sh
# exit 0 only on the active, unsealed node:
# /v1/sys/health answers 200 on the active node, 429 on a standby, 503 when sealed
exec /usr/bin/curl -fsS -o /dev/null --max-time 2 \
     --cacert /opt/openbao/tls/ca.pem https://127.0.0.1:8200/v1/sys/healthCode language: PHP (php)
chmod 0755 /usr/local/libexec/keepalived/check_bao_active.sh
useradd --system --no-create-home --shell /usr/sbin/nologin keepalived_script

/etc/keepalived/keepalived.conf on bao-01 (on the others: router_id, priority 99 and 98, unicast_src_ip, unicast_peer):

global_defs {
    router_id bao-01
    enable_script_security
    script_user keepalived_script
    vrrp_garp_master_refresh 60
}

vrrp_script chk_bao_active {
    script "/usr/local/libexec/keepalived/check_bao_active.sh"
    interval 2
    timeout 3
    rise 1
    fall 2
    weight 50
}

vrrp_instance VI_BAO {
    state BACKUP
    interface ens192
    virtual_router_id 62
    priority 100
    advert_int 1

    unicast_src_ip 10.20.0.61
    unicast_peer {
        10.20.0.62
        10.20.0.63
    }
    check_unicast_src

    authentication {
        auth_type PASS
        auth_pass Rb4tWq9z
    }

    virtual_ipaddress {
        10.20.0.60/24 dev ens192
    }

    track_script {
        chk_bao_active
    }
}Code language: PHP (php)
keepalived -t -f /etc/keepalived/keepalived.conf && systemctl enable --now keepalived

The active node gets 100 + 50, the standbys stay at 99 and 98, so the VIP sits on the active node. When leadership moves (failure, bao operator step-down, an upgrade), the bonus moves within a few seconds, and so does the VIP. The weight is positive here: the check doesn’t fail on standbys, it simply doesn’t add anything.

From now on, everyone uses:

export BAO_ADDR=https://bao.mydomain.local:8200
export BAO_CACERT=/usr/local/share/ca-certificates/mydomain-ca.crtCode language: JavaScript (javascript)

11. Policies

Policies are files. Keep them in git and apply them with bao policy write.

bao-admin.hcl, for the platform team. It’s broad on purpose, and it’s the reason they log in with MFA:

path "*" {
  capabilities = ["create", "read", "update", "patch", "delete", "list", "sudo"]
}Code language: JavaScript (javascript)

team-web.hcl, a typical application team: their own KV path, their own database role, nothing else:

path "kv/data/team-web/*"     { capabilities = ["create", "read", "update", "patch", "delete", "list"] }
path "kv/metadata/team-web/*" { capabilities = ["read", "list", "delete"] }
path "database/creds/web-app" { capabilities = ["read"] }Code language: JavaScript (javascript)

raft-snapshot.hcl, for the backup job (section 18):

path "sys/storage/raft/snapshot" { capabilities = ["read"] }Code language: JavaScript (javascript)

metrics.hcl, for Prometheus (section 19):

path "sys/metrics" { capabilities = ["read", "list"] }Code language: JavaScript (javascript)
for p in bao-admin team-web raft-snapshot metrics; do bao policy write "$p" "$p.hcl"; done
bao policy listCode language: PHP (php)

12. Login with authentik (OIDC)

People log in through authentik, which checks their AD password and enforces MFA. OpenBao gets their AD groups in the token. The OIDC method is built into OpenBao.

12.1 In authentik

Applications โ†’ Applications โ†’ Create with provider:

  • Application OpenBao, slug openbao
  • Provider OAuth2/OpenID Connect, client type Confidential
  • Redirect URIs (strict):
  • https://bao.mydomain.local:8200/ui/vault/auth/oidc/oidc/callback for the web UI
  • http://localhost:8250/oidc/callback for bao login -method=oidc on a workstation
  • Scopes openid, profile, email. authentik’s profile scope includes the user’s groups.
  • Bindings: the AD groups that may use OpenBao at all

12.2 In OpenBao

bao auth enable oidc

bao write auth/oidc/config \
    oidc_discovery_url="https://auth.mydomain.local/application/o/openbao/" \
    oidc_discovery_ca_pem=@/usr/local/share/ca-certificates/mydomain-ca.crt \
    oidc_client_id="<client id from authentik>" \
    oidc_client_secret="<client secret from authentik>" \
    default_role="default"

bao write auth/oidc/role/default \
    user_claim="preferred_username" \
    groups_claim="groups" \
    oidc_scopes="openid,profile,email" \
    allowed_redirect_uris="https://bao.mydomain.local:8200/ui/vault/auth/oidc/oidc/callback,http://localhost:8250/oidc/callback" \
    policies="default" \
    ttl="8h"Code language: JavaScript (javascript)

12.3 AD groups to policies

OIDC groups become external identity groups, each linked to a policy:

ACC=$(bao auth list -format=json | jq -r '."oidc/".accessor')

GID=$(bao write -field=id identity/group name="bao-admins" type="external" policies="bao-admin")
bao write identity/group-alias name="GG-OpenBao-Admins" mount_accessor="$ACC" canonical_id="$GID"

GID=$(bao write -field=id identity/group name="team-web" type="external" policies="team-web")
bao write identity/group-alias name="GG-Team-Web" mount_accessor="$ACC" canonical_id="$GID"Code language: JavaScript (javascript)

The alias name must be the group name exactly as it appears in the groups claim. Log in to test it:

bao login -method=oidc          # opens the browser, authentik with MFA
bao token lookup | grep -E 'display_name|policies|ttl'Code language: PHP (php)

In the web UI, choose method OIDC and click Sign in with OIDC Provider.


13. Login with Active Directory (LDAP plugin)

For direct AD login (a fallback when authentik is down, or for tools that can’t do a browser flow), there’s the LDAP method. Since OpenBao 2.7 it’s no longer in the main binary. It’s an external plugin from the openbao-plugins project.

13.1 Install the plugin

Download the LDAP auth plugin binary from the openbao-plugins releases on GitHub, check its SHA-256 against the published digest, and install it root-owned:

install -m 0755 -o root -g root openbao-plugin-auth-ldap /usr/local/libexec/openbao-plugins/
sha256sum /usr/local/libexec/openbao-plugins/openbao-plugin-auth-ldap

Declare it in /etc/openbao/openbao.hcl on every node, with the version and checksum from the release:

plugin "auth" "ldap" {
  command   = "openbao-plugin-auth-ldap"
  version   = "v<plugin version>"
  sha256sum = "<sha256 of the binary>"
}Code language: JavaScript (javascript)

Reload one node at a time (systemctl reload openbao), standbys first, then enable it once:

bao auth enable ldap

13.2 Configure it for AD

A read-only service account in AD, as for authentik. Then:

bao write auth/ldap/config \
    url="ldaps://dc01.mydomain.local,ldaps://dc02.mydomain.local" \
    certificate=@/usr/local/share/ca-certificates/mydomain-ca.crt \
    insecure_tls=false \
    binddn="CN=svc-openbao,OU=Service Accounts,DC=mydomain,DC=local" \
    bindpass="<service account password>" \
    userdn="OU=Users,OU=Corp,DC=mydomain,DC=local" \
    userattr="sAMAccountName" \
    upndomain="mydomain.local" \
    groupdn="OU=Groups,OU=Corp,DC=mydomain,DC=local" \
    groupfilter="(&(objectClass=group)(member:1.2.840.113556.1.4.1941:={{.UserDN}}))" \
    groupattr="cn" \
    token_ttl="8h"Code language: JavaScript (javascript)
  • ldaps:// with your CA, never insecure_tls=true. Windows Server 2025 requires signed or encrypted LDAP anyway.
  • The groupfilter with 1.2.840.113556.1.4.1941 resolves nested AD groups.
  • Two DCs in the URL: the next one is used if the first is down.

Map AD groups to policies:

bao write auth/ldap/groups/GG-OpenBao-Admins policies="bao-admin"
bao write auth/ldap/groups/GG-Team-Web       policies="team-web"

bao login -method=ldap username=jdoeCode language: JavaScript (javascript)

Group changes in AD take effect at the next login. Existing tokens keep their policies until they expire, which is one more reason for short TTLs. After five failed logins, the method locks the user out for 15 minutes.

LDAP login has no MFA. If you use it for more than break-glass, limit it to admin networks with token_bound_cidrs on the mount, or keep humans on OIDC.


14. Machines: AppRole

Servers and scripts log in with AppRole: a role_id (like a username, not secret) and a secret_id (short-lived, single use if you want). Bind both to the machine’s address:

bao auth enable approle

bao write auth/approle/role/web01 \
    token_policies="team-web" \
    token_ttl="1h" token_max_ttl="4h" \
    secret_id_ttl="24h" secret_id_num_uses=1 \
    secret_id_bound_cidrs="10.20.40.11/32" \
    token_bound_cidrs="10.20.40.11/32"

bao read -field=role_id auth/approle/role/web01/role-id
bao write -f -field=secret_id auth/approle/role/web01/secret-idCode language: JavaScript (javascript)

The secret_id is delivered once, by your deployment tool, and can only be used once and only from 10.20.40.11. A stolen copy from a log file or a ticket is worth nothing.

On the machine, OpenBao Agent (bao agent) logs in, keeps the token renewed and renders secrets into files for applications that can’t speak to OpenBao themselves.


15. Static secrets: KV v2

bao secrets enable -path=kv kv-v2
bao kv metadata put -max-versions=10 -delete-version-after=2160h kv/team-web

bao kv put kv/team-web/smtp username=web@mydomain.local password="$(openssl rand -base64 24)"
bao kv get kv/team-web/smtp
bao kv get -field=password kv/team-web/smtp
bao kv get -version=1 kv/team-web/smtp       # older versions stay availableCode language: JavaScript (javascript)

KV v2 keeps versions, so an overwritten secret can be restored. The policy paths contain data/ and metadata/ (section 11), even though the CLI hides them.


16. Dynamic PostgreSQL credentials on Patroni

Instead of one database password that lives in a config file for years, the application asks OpenBao for credentials, gets a user that exists for one hour, and OpenBao drops it afterwards.

16.1 In PostgreSQL (on the Patroni leader)

A dedicated management user for OpenBao, and a group role that carries the application’s permissions. The dynamic users only become members of that group:

CREATE ROLE openbao LOGIN CREATEROLE PASSWORD 'temporary-will-be-rotated';

CREATE ROLE web_app NOLOGIN;
GRANT CONNECT ON DATABASE webdb TO web_app;
\c webdb
GRANT USAGE ON SCHEMA public TO web_app;
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO web_app;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO web_app;

GRANT web_app TO openbao WITH ADMIN OPTION;Code language: PHP (php)

Since PostgreSQL 16, CREATEROLE no longer means “can grant anything”. openbao may only hand out the roles it holds with admin option. That’s exactly what you want: it can create users that are members of web_app, and nothing more.

Allow the three OpenBao nodes in Patroni’s pg_hba (patronictl edit-config), TLS only:

    - hostssl all openbao 10.20.0.61/32 scram-sha-256
    - hostssl all openbao 10.20.0.62/32 scram-sha-256
    - hostssl all openbao 10.20.0.63/32 scram-sha-256
    - hostssl webdb +web_app 10.20.40.0/24 scram-sha-256

16.2 In OpenBao

Copy the Patroni CA to the nodes as /opt/openbao/tls/pg-ca.crt, then:

bao secrets enable database

bao write database/config/patroni \
    plugin_name="postgresql-database-plugin" \
    connection_url="postgresql://{{username}}:{{password}}@pg.mydomain.local:5432/webdb?sslmode=verify-ca&sslrootcert=/opt/openbao/tls/pg-ca.crt" \
    username="openbao" \
    password="temporary-will-be-rotated" \
    password_authentication="scram-sha-256" \
    allowed_roles="web-app"

# from now on, only OpenBao knows the management password
bao write -force database/rotate-root/patroni

bao write database/roles/web-app \
    db_name="patroni" \
    creation_statements="CREATE ROLE \"{{name}}\" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}' IN ROLE web_app;" \
    default_ttl="1h" \
    max_ttl="24h"Code language: PHP (php)
  • pg.mydomain.local is the Patroni leader VIP. After a failover, OpenBao reconnects to the new leader through the same name.
  • rotate-root replaces the password you typed with one only OpenBao knows. Nobody can log in as openbao any more, not even you.
  • VALID UNTIL '{{expiration}}': even if OpenBao were gone, PostgreSQL itself would refuse the user after the lease.

16.3 Using it

bao read database/creds/web-app
Key                Value
---                -----
lease_id           database/creds/web-app/XyZ...
lease_duration     1h
username           v-approle-web-app-8Kf2...
password           A1b-...

The application (or OpenBao Agent on its behalf) renews the lease while it runs. When it stops, the lease runs out and the user is dropped. Revoke everything at once after an incident:

bao lease revoke -prefix database/creds/web-app

17. Retiring the root token

The initial root token can do everything and never expires. Once OIDC (section 12) works and you’ve logged in with bao-admin, revoke it:

bao login -method=oidc        # check: policies include bao-admin
bao token revoke <initial root token>Code language: HTML, XML (xml)

When you need root again (everything else is broken), three of the five recovery key holders generate a new one together:

bao operator generate-root -init          # prints an OTP and a nonce
bao operator generate-root                # each key holder, with the nonce
bao operator generate-root -decode=<encoded token> -otp=<otp>Code language: PHP (php)

Use it, fix the problem, revoke it again. Every step shows up in the audit log.


18. Backups: Raft snapshots

A Raft snapshot contains everything: secrets, policies, configuration, leases. It’s encrypted with the seal key, so you need that key (section 6.2’s offline copy) to restore it.

A token that may only take snapshots, on a backup host:

bao token create -orphan -policy=raft-snapshot -period=768h -display-name=raft-backup -field=token \
    > /etc/openbao-backup/token
chmod 0600 /etc/openbao-backup/tokenCode language: JavaScript (javascript)

/usr/local/sbin/bao-snapshot on the backup host:

#!/bin/bash
set -euo pipefail
export BAO_ADDR=https://bao.mydomain.local:8200
export BAO_CACERT=/usr/local/share/ca-certificates/mydomain-ca.crt
export BAO_TOKEN=$(cat /etc/openbao-backup/token)
OUT=/srv/backup/openbao/raft-$(date +%Y%m%d-%H%M).snap
bao operator raft snapshot save "$OUT"
bao token renew >/dev/null                      # keep the periodic token alive
find /srv/backup/openbao -name 'raft-*.snap' -mtime +30 -deleteCode language: PHP (php)

Run it hourly with a systemd timer, and copy the snapshots off-site with the rest of your backups.

Restore into a cluster with the same seal key:

bao operator raft snapshot restore -force raft-20261123-0300.snapCode language: CSS (css)

Practise the restore on a test cluster once a quarter. A snapshot you’ve never restored isn’t a backup yet.


19. Monitoring

Metrics come from the active node at /v1/sys/metrics, with a token. Give Prometheus a periodic token with the metrics policy (section 11), stored in a file:

  - job_name: openbao
    scheme: https
    metrics_path: /v1/sys/metrics
    params:
      format: [ 'prometheus' ]
    bearer_token_file: /etc/prometheus/secrets/openbao-token
    tls_config:
      ca_file: /etc/prometheus/mydomain-ca.pem
    static_configs:
      - targets: [ 'bao.mydomain.local:8200' ]

  - job_name: openbao-nodes
    metrics_path: /probe
    params:
      module: [ http_2xx ]
    static_configs:
      - targets:
          - 'https://bao-01.mydomain.local:8200/v1/sys/health?standbyok=true'
          - 'https://bao-02.mydomain.local:8200/v1/sys/health?standbyok=true'
          - 'https://bao-03.mydomain.local:8200/v1/sys/health?standbyok=true'
    relabel_configs:
      - source_labels: [ __address__ ]
        target_label: __param_target
      - target_label: __address__
        replacement: blackbox-exporter:9115Code language: PHP (php)

?standbyok=true makes standbys answer 200. A node that’s sealed answers 503 and turns the probe red, which is exactly what you want to know.

Alert on:

  • Any node not healthy (probe_success{job="openbao-nodes"} == 0): sealed, down, or out of the cluster.
  • No active node (the VIP job is down).
  • Leadership changes many times an hour: network or disk problems. Use the Raft and leadership metrics, whose names start with the vault_ prefix by default.
  • Audit device errors: requests fail if no audit device can write.
  • The snapshot job hasn’t produced a file in two hours.

20. Day-2 operations and upgrades

TaskCommand
Cluster statebao status, bao operator raft list-peers, bao operator raft autopilot state
Move leadership away (maintenance)bao operator step-down on the active node
Remove a dead nodebao operator raft remove-peer bao-03
Replace a nodeNew VM with the same name: install, certificate, encrypt the seal key with its TPM (6.2), start; it joins through retry_join
Renew TLS certificatesCopy the new files; tls_auto_reload picks them up
Rotate the encryption keybao operator rotate (new data key, old data stays readable)
Who has access to whatbao list identity/group/name, bao read identity/group/name/bao-admins

Upgrades, one node at a time, standbys first:

  1. Read the release notes. OpenBao is deprecating and moving features to plugins between releases (2.7 moved LDAP, Kerberos, RADIUS and the cloud KMS seals out; 2.8 drops the legacy plugin protocol). Check that your plugins have matching releases.
  2. Take a snapshot (section 18).
  3. On a standby: download and verify the new package (section 4), apt install ./openbao_...deb, systemctl restart openbao, then bao status until it’s unsealed and in the cluster.
  4. The second standby, the same way.
  5. On the active node: bao operator step-down, wait until the VIP has moved, then upgrade it.

The cluster stays available throughout. Only the leadership moves once.


21. Troubleshooting

SymptomCheckLikely cause
Node stays sealed after startjournalctl -u openbao, ls /run/credentials/openbao.service/Credential not loaded (drop-in missing, TPM changed), wrong key on this node
systemd-creds decrypt fails after a VM changesystemd-analyze has-tpm2vTPM re-created or removed; re-encrypt from the offline key copy
New node doesn’t joinjournalctl -u openbao on the new noderetry_join name or CA wrong, port 8201 blocked, certificate without clientAuth
x509: certificate is valid for ..., not ...openssl x509 -in /opt/openbao/tls/tls.crt -noout -ext subjectAltNameNode or VIP name, or 127.0.0.1, missing from the SANs
All requests fail: “failed to log … audit”df -h /var/log, the journalNo audit device can write; free space, check the second device
VIP not on the active nodejournalctl -u keepalived, run the check script by handCheck script fails (CA path), VRRP blocked
OIDC: redirect_uri errorauthentik provider settingsThe callback URL doesn’t match exactly, including the port :8200
OIDC login works, but no policiesbao token lookupGroup alias name doesn’t match the groups claim
bao auth enable ldap: unknown pluginbao plugin list authPlugin block missing on the active node, wrong checksum, or binary not executable
Database creds: permission denied for GRANTPostgreSQL logopenbao lacks WITH ADMIN OPTION on the group role (PostgreSQL 16+)
Database creds fail after a Patroni failoverbao read database/config/patroniConnection URL points at a node instead of the leader VIP

22. Checklist

  • โ˜ Three dedicated VMs on different hosts, vTPM and Secure Boot, swap off
  • โ˜ Package verified with GPG and SHA-256 before installing
  • โ˜ Per-node certificates from your CA with node name, VIP, IPs and 127.0.0.1; tls_auto_reload on
  • โ˜ Seal key encrypted with each node’s TPM; plaintext shredded; offline copy in a safe
  • โ˜ Raft with retry_join and CA verification; three voters in list-peers
  • โ˜ Two declarative audit devices; audit log rotated and shipped to the SIEM
  • โ˜ Plugin directory root-owned; LDAP plugin pinned by version and checksum
  • โ˜ nftables: 8200 for clients, 8201 and VRRP only between the nodes
  • โ˜ keepalived VIP follows the active node
  • โ˜ Policies in git; humans via authentik OIDC with MFA; AD groups mapped to policies
  • โ˜ LDAP login only as fallback, limited by network
  • โ˜ Machines via AppRole with single-use, CIDR-bound secret IDs
  • โ˜ Dynamic PostgreSQL users with 1 h leases, rotate-root done
  • โ˜ Initial root token revoked; recovery keys with five different people
  • โ˜ Hourly Raft snapshots off-site; restore practised
  • โ˜ Prometheus: metrics from the active node, health probes per node, alerts in place
  • โ˜ Upgrade runbook: snapshot, standbys first, step-down, plugins checked