You want one place to keep application secrets, you want the application to fetch them at boot rather than read them from a file baked into an image, and you would rather not adopt a licence you have to explain to a lawyer. OpenBao is the community fork of HashiCorp Vault, taken from the last MPL 2.0 release before HashiCorp moved Vault to the Business Source License in August 2023, and developed since under the Linux Foundation. The CLI is bao, the environment variables are BAO_*, and the command surface is close enough to Vault’s that most Vault muscle memory transfers. This guide builds one node end to end: a systemd service on TLS with integrated raft storage, an initialised and unsealed core, a KV v2 mount, a policy that grants read on exactly one path prefix, and an application that logs in with an AppRole role_id and secret_id and renews its own token. It also states plainly what one node costs you, because the honest answer is a service that stops answering every time it restarts.
What you’ll accomplish
- Run OpenBao as an unprivileged systemd service listening on TLS, with raft storage on local disk.
- Initialise the cluster with five key shares and a threshold of three, and know where those shares are allowed to live.
- Enable a KV v2 mount and write a secret an application actually needs.
- Write a policy granting read on
kv/data/apps/billing/*and nothing else, and prove the “nothing else” half. - Issue an application a
role_idand a response-wrappedsecret_id, and watch it renew its own token before expiry.
Prerequisites
- A Debian 12 / Ubuntu 22.04 or newer host, or a RHEL 9 family host, with
rootorsudo. 2 vCPU and 2 GB RAM is plenty for a single node serving a handful of applications. - OpenBao 2.x. Confirm with
bao versionafter install. Anything written here that touches auth methods, policies or KV v2 mirrors Vault’s CLI; the flags exist in both. Where OpenBao and Vault differ is mostly in packaging, telemetry and the enterprise features that were never in the fork’s ancestry, so do not assume a Vault Enterprise feature you read about is present. - DNS for the server name you will put in the certificate.
bao.example.internalis used throughout. An IP-only deployment works but you will be maintaining an IP SAN forever. - A decision, made before you run
bao operator init, about where the unseal key shares go. They must not live on this host, must not live in the same password vault as the root token, and ideally are split across people. Five shares emailed to yourself is not a threshold scheme; it is one share with extra steps. - A second host or a workstation with the
baobinary on it, so you test the client path over the network rather than over loopback.
How it works
An OpenBao server keeps its data encrypted at rest with a data encryption key, which is itself encrypted with a master key. On a fresh start the master key is not in memory, so the server is sealed: it answers /v1/sys/health and nothing else, and every real API call returns 503. bao operator init generates the master key, splits it into Shamir shares, and prints them once. bao operator unseal, run once per share until the threshold is met, reconstructs the master key in RAM and the server becomes active.
Nothing about that is automatic. A reboot, a systemctl restart, an OOM kill, or a bao operator seal puts you back at sealed, and a human with three shares has to turn up. Auto-unseal, where the master key is wrapped by an external KMS or by another OpenBao’s transit engine, removes the human but adds a dependency that must be online before this server can serve anything.
Everything past the seal is tokens. A token carries a set of policies, a TTL, and a maximum TTL. Applications do not get long-lived tokens; they get a way to obtain short ones. That is what AppRole is for. The role is split into two credentials on purpose: the role_id is stable and behaves like a username, so it can sit in a config file or a systemd drop-in; the secret_id is the password half, is short-lived, can be limited to a number of uses and to source CIDRs, and should be delivered separately. Present both to auth/approle/login and you get a token whose policies come from the role, not from the caller.
The policy is the gate every request passes through. It grants capabilities on paths, and a path with no matching rule is denied. That is why the second read in the diagram fails without anyone configuring a denial.
Step-by-step
-
Install the binary and create the service account. OpenBao publishes
.deb,.rpmand static archives on its releases page. Check the exact asset name there first, because it has changed shape across 2.x releases.BAO_VERSION=2.6.1 curl -sSLO "https://github.com/openbao/openbao/releases/download/v${BAO_VERSION}/openbao_${BAO_VERSION}_linux_amd64.deb" sudo dpkg -i "openbao_${BAO_VERSION}_linux_amd64.deb" bao versionExpected:
bao versionprints the version and build date. The package creates theopenbaosystem user and a data directory; if you installed from the static archive instead, create them yourself:sudo useradd --system --home /var/lib/openbao --shell /usr/sbin/nologin openbao sudo install -d -o openbao -g openbao -m 0700 /var/lib/openbao/data sudo install -d -o root -g openbao -m 0750 /etc/openbao/tls -
Issue a TLS certificate. Use your internal CA if you have one. If you do not, a self-signed certificate with a correct SAN is still far better than running without TLS, which would put every token on the wire in clear text.
sudo openssl req -x509 -newkey rsa:4096 -sha256 -days 825 -nodes \ -keyout /etc/openbao/tls/bao.key -out /etc/openbao/tls/bao.crt \ -subj "/CN=bao.example.internal" \ -addext "subjectAltName=DNS:bao.example.internal,IP:10.0.10.20" sudo chown root:openbao /etc/openbao/tls/bao.key sudo chmod 0640 /etc/openbao/tls/bao.keyExpected: two files in
/etc/openbao/tls. Verify the SAN landed, because a certificate without one is rejected outright by modern clients:openssl x509 -in /etc/openbao/tls/bao.crt -noout -text | grep -A1 "Subject Alternative Name"Expected: a line reading
DNS:bao.example.internal, IP Address:10.0.10.20. -
Write the server configuration. Raft integrated storage keeps data in the node’s own directory and leaves the door open to adding nodes later.
sudo tee /etc/openbao/openbao.hcl >/dev/null <<'EOF' ui = true cluster_name = "bao-prod-01" disable_mlock = true storage "raft" { path = "/var/lib/openbao/data" node_id = "bao-01" } listener "tcp" { address = "0.0.0.0:8200" tls_cert_file = "/etc/openbao/tls/bao.crt" tls_key_file = "/etc/openbao/tls/bao.key" tls_min_version = "tls12" } api_addr = "https://bao.example.internal:8200" cluster_addr = "https://bao.example.internal:8201" EOF sudo chown root:openbao /etc/openbao/openbao.hcl sudo chmod 0640 /etc/openbao/openbao.hcldisable_mlock = trueis the inherited recommendation for integrated storage: the raft database is memory-mapped, and locking it would pin the entire file into RAM. The trade is that decrypted secrets can reach swap, so turn swap off on this host (sudo swapoff -aplus the matching/etc/fstabedit) rather than skipping the setting. -
Install the systemd unit and start the service. The package ships one at
/usr/lib/systemd/system/openbao.service; the version below is what a static-archive install needs, and it is worth reading either way.sudo tee /etc/systemd/system/openbao.service >/dev/null <<'EOF' [Unit] Description=OpenBao Documentation=https://openbao.org/docs/ Requires=network-online.target After=network-online.target ConditionFileNotEmpty=/etc/openbao/openbao.hcl [Service] User=openbao Group=openbao ProtectSystem=full ProtectHome=read-only PrivateTmp=yes PrivateDevices=yes NoNewPrivileges=yes ExecStart=/usr/bin/bao server -config=/etc/openbao/openbao.hcl ExecReload=/bin/kill --signal HUP $MAINPID KillSignal=SIGINT Restart=on-failure RestartSec=5 LimitNOFILE=65536 [Install] WantedBy=multi-user.target EOF sudo systemctl daemon-reload sudo systemctl enable --now openbao systemctl status openbao --no-pagerExpected:
Active: active (running), andjournalctl -u openbao -n 20ending with a startup banner listing the listener, the storage type andSeal Type: shamir. A unit that restarts in a loop is almost always a config parse error or an unreadable key file; the journal names both. -
Point your client at the server. Every command from here needs the address and, for a self-signed certificate, the CA file.
export BAO_ADDR=https://bao.example.internal:8200 export BAO_CACERT=/etc/openbao/tls/bao.crt bao statusExpected:
Initialized false,Sealed true, and a non-zero exit status. That exit status is normal —bao statusreturns 2 when sealed, which is useful in monitoring scripts and confusing the first time. -
Initialise the cluster. This is the one command whose output cannot be recovered.
bao operator init -key-shares=5 -key-threshold=3Expected: five
Unseal Keylines and oneInitial Root Tokenline. Distribute the shares now, to separate holders, and record nothing on this host. Treat the root token as a break-glass credential: use it for the setup below, then revoke it withbao token revoke -selfonce you have another admin path. -
Unseal the server. Run this three times, once per share, from three different holders if your process demands it.
bao operator unsealExpected: after the first two shares,
Sealed truewithUnseal Progress 1/3then2/3; after the third,Sealed false,Storage Type raftand anHA Modeofactive. Confirm withbao statusbefore moving on. -
Enable KV v2 and write the first secret.
export BAO_TOKEN=<the-initial-root-token> bao secrets enable -path=kv kv-v2 bao kv put -mount=kv apps/billing/config \ db_password='rotate-me-now' \ stripe_key='sk_test_placeholder'Expected:
Success! Enabled the kv-v2 secrets engine at: kv/, then a version table showingversion 1and acreated_time. Read it back withbao kv get -mount=kv apps/billing/config. Note the mismatch you are about to meet in policy: the CLI takesapps/billing/config, but the API path iskv/data/apps/billing/config. -
Write the least-privilege policy.
sudo install -d -m 0750 -o root -g openbao /etc/openbao/policies sudo tee /etc/openbao/policies/app-billing.hcl >/dev/null <<'EOF' path "kv/data/apps/billing/*" { capabilities = ["read"] } path "kv/metadata/apps/billing/*" { capabilities = ["read", "list"] } EOF bao policy write app-billing /etc/openbao/policies/app-billing.hcl bao policy read app-billingExpected:
Success! Uploaded policy: app-billing, then the file echoed back. Two rules, because KV v2 splits data from metadata: without themetadatarule the application cannot list versions or see when a secret last changed. You do not need a rule forauth/token/renew-self— the built-indefaultpolicy is attached to every token and already grants it, unless you settoken_no_default_policy=trueon the role. -
Enable AppRole and create the role.
bao auth enable approle bao write auth/approle/role/app-billing \ token_policies="app-billing" \ token_ttl=20m \ token_max_ttl=4h \ secret_id_ttl=24h \ secret_id_num_uses=0 \ bind_secret_id=true \ secret_id_bound_cidrs="10.0.20.0/24" \ token_bound_cidrs="10.0.20.0/24" bao read auth/approle/role/app-billingExpected:
Success! Enabled approle auth method at: approle/, thenSuccess! Data written to: auth/approle/role/app-billing, then the role echoed with those fields.token_ttlis how long each login is good for,token_max_ttlcaps how long renewals can extend it before a fresh login is required, and the two CIDR bindings mean a stolen credential is useless outside your application subnet. -
Hand the application its credentials. The
role_idis stable and can go into configuration management. Thesecret_idshould not: generate it wrapped, so the value crosses the wire exactly once and a second reader gets an error instead of a secret.bao read -field=role_id auth/approle/role/app-billing/role-id bao write -f -wrap-ttl=120s auth/approle/role/app-billing/secret-idExpected: a UUID for the
role_id, and for the second command awrapping_tokenwith a 120 second TTL and nosecret_idin sight. On the application host, exchange it:bao unwrap "$WRAP_TOKEN"Expected: the
secret_idand its accessor. Runbao unwrapa second time with the same token and you getwrapping token is not valid or does not exist— which is exactly how you detect interception. Write thesecret_idto atmpfspath the service unit owns, never to/etc.
Validate it works
Log in as the application would, from the application host, and check both halves of the policy.
ROLE_ID=<the-role-id>
SECRET_ID=<the-unwrapped-secret-id>
APP_TOKEN=$(bao write -field=token auth/approle/login \
role_id="$ROLE_ID" secret_id="$SECRET_ID")
BAO_TOKEN="$APP_TOKEN" bao token lookup
Expected: a table with policies of [app-billing default], a ttl counting down from 20 minutes, and renewable true. If policies shows only default, the role was created without token_policies.
Now the allowed read, then the denied one:
BAO_TOKEN="$APP_TOKEN" bao kv get -mount=kv apps/billing/config
BAO_TOKEN="$APP_TOKEN" bao kv get -mount=kv apps/payroll/config
Expected: the first prints the key-value table. The second prints Error reading kv/data/apps/payroll/config: Error making API request with Code: 403 and permission denied. That denial is the whole point of the exercise — a setup that has not been shown to refuse anything has not been tested.
Finally, prove renewal, which is what keeps the application from re-authenticating every twenty minutes:
BAO_TOKEN="$APP_TOKEN" bao token renew
Expected: token_duration back at 20 minutes. Have your service renew at roughly two-thirds of the TTL, and fall back to a full AppRole login when renewal fails or token_max_ttl is reached.
Troubleshooting
- Everything returns 503 after a reboot.
bao statusshowsSealed true. This is designed behaviour, not a fault: the master key lives only in RAM. Runbao operator unsealthree times. If this happens often enough to hurt, that is the signal to configure auto-unseal against a KMS or a separate transit instance — and to accept that the wrapping key then becomes a dependency of your dependency. permission deniedon a path the policy clearly grants. Nearly always the KV v2 path split. A policy written againstkv/apps/billing/*grants nothing, because the API path iskv/data/apps/billing/*. Ask the server directly instead of guessing:BAO_TOKEN="$APP_TOKEN" bao read sys/capabilities-self path=kv/data/apps/billing/configreturns the capability list that actually applies.x509: certificate signed by unknown authorityorcertificate is valid for ... not .... The first meansBAO_CACERTis unset or points at the wrong file. The second means you are connecting by a name or IP that is not in the SAN — commonlyBAO_ADDRset tohttps://localhost:8200against a certificate issued for the DNS name. Fix the address rather than reaching for-tls-skip-verify, which turns off the check that protects the token in transit.- The token works, then stops after twenty minutes.
bao token lookupon an expired token returnsbad token. Either renewal is not running, or it has been running for four hours and hittoken_max_ttl, at which point renewal stops extending and only a fresh login helps. Both are expected; a service that cannot re-login on its own is the actual bug. failed to validate SecretIDon login. Thesecret_idexpired after itssecret_id_ttl, was already consumed if you setsecret_id_num_uses, or the request arrived from outsidesecret_id_bound_cidrs. Issue a new one, and usebao list auth/approle/role/app-billing/secret-idto see how many are outstanding.
When this is the wrong approach
One node is one node. It is sealed after every restart, it has no replica to fail over to, and while it is down every application that fetches secrets at startup cannot start. That is acceptable for a small estate where secrets are read at deploy time and cached in memory; it is not acceptable if a five-minute outage stops customer traffic. Before you scale this pattern, take snapshots — raft storage supports bao operator raft snapshot save, and a stopped-service tar of the data directory works too — and rehearse the restore, because a secrets server you cannot rebuild is worse than a file you can read.
If your workloads already run on a cloud provider, that provider’s KMS-backed secrets manager gives you the availability, audit trail and IAM integration you would otherwise be building and operating yourself. If your secrets are configuration values that belong beside the code in git, an encrypted-in-repo approach fits better than a server — our guide to SOPS with age in a Flux GitOps repository covers that path. And if the consumers are all Kubernetes pods, AppRole is the wrong auth method: pods already carry a ServiceAccount token you can bind to a role, which is the model in our Vault Agent Injector guide and works the same way here.
The authoritative references are the OpenBao documentation and the openbao repository, whose release notes are the only reliable source for which flags exist in the version you installed.
If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.