On this page
- What should you know before installing Vault?
- How do you install Vault from the official repository?
- How do you configure Vault with Raft storage?
- How do you initialise and unseal Vault?
- How do you store and read a first secret?
- How do you put the UI and API behind HTTPS?
- How do you back up and upgrade Vault?
- What are the usual problems?
- Questions
What should you know before installing Vault?
Vault is a single Go binary that keeps secrets encrypted at rest and only decrypts them while it is unsealed in memory. A small plan is enough for a single node, but treat the server as sensitive: nothing else public should run on it.
- Licence: releases from 1.14 onward are published under the Business Source License 1.1, a source-available licence. Running Vault for your own applications is covered; if you plan to offer Vault itself as a hosted product to others, read the licence terms first. The community fork OpenBao keeps the earlier open source licence and the same workflow.
- Hostname: for example
vault.example.net, with records set as in DNS records. - Access: a sudo user with SSH keys, as set up in SSH keys and hardening.
How do you install Vault from the official repository?
Import the HashiCorp signing key, add the repository for your release codename and install the package. The package creates a vault system user, a systemd unit and a default config.
sudo apt update
sudo apt install -y gpg wget lsb-release
wget -O- https://apt.releases.hashicorp.com/gpg | \
sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \
sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update
sudo apt install -y vault
vault versionThe version line confirms the install. If apt update reports that your codename is missing from the repository (it can lag behind a brand-new Debian release for a while), check the repository index and wait, or use the static binary from the release page for that period.
How do you configure Vault with Raft storage?
Replace the default config with one that uses integrated Raft storage on local disk and listens only on loopback. TLS terminates at the reverse proxy, so the internal listener can stay plain HTTP on 127.0.0.1.
sudo tee /etc/vault.d/vault.hcl >/dev/null <<'EOF'
ui = true
disable_mlock = true
storage "raft" {
path = "/opt/vault/data"
node_id = "vault-1"
}
listener "tcp" {
address = "127.0.0.1:8200"
tls_disable = 1
}
api_addr = "https://vault.example.net"
cluster_addr = "http://127.0.0.1:8201"
EOF
sudo chown vault:vault /etc/vault.d/vault.hcl
sudo chmod 640 /etc/vault.d/vault.hcl
sudo systemctl enable --now vault
systemctl status vault --no-pagerWith Raft storage the documentation recommends disable_mlock = true, and the systemd unit shipped with the package already limits what the process may do. Swap should still be kept small or disabled on this server so secrets in memory are less likely to reach disk.
How do you initialise and unseal Vault?
Initialise once, store the output somewhere safe and offline, then feed three different unseal keys to bring the server online.
export VAULT_ADDR=http://127.0.0.1:8200
vault status
vault operator init -key-shares=5 -key-threshold=3
vault operator unseal # paste key 1
vault operator unseal # paste key 2
vault operator unseal # paste key 3
vault statusThe init command prints five unseal keys and one initial root token, and it never shows them again. Give the keys to different people or store them in separate places; any three of them can unseal the server, and losing more than two means the data can never be decrypted. After a reboot or a service restart Vault starts sealed, and vault status shows Sealed true until the threshold of keys is entered again. That is by design: a stolen disk image reveals nothing.
How do you store and read a first secret?
Log in with the root token, enable a version 2 key-value engine and write a value; then create a narrow policy and token for the application so the root token can be put away.
vault login
vault secrets enable -path=secret kv-v2
vault kv put secret/shop/db username=shop password='Long-Random-Value'
vault kv get secret/shop/db
vault policy write shop-read - <<'EOF'
path "secret/data/shop/*" {
capabilities = ["read"]
}
EOF
vault token create -policy=shop-read -period=24hNotice that the policy path contains data/: that is how KV version 2 lays out its API. For services, the AppRole auth method (vault auth enable approle) is a better long-term fit than handing out tokens by hand. When you are done, revoke the root token with vault token revoke <token> and create a new one later with vault operator generate-root if you ever need it.
How do you put the UI and API behind HTTPS?
Proxy vault.example.net to the loopback listener with Nginx and a Let's Encrypt certificate. A minimal server block:
server {
listen 80;
listen [::]:80;
server_name vault.example.net;
location / {
proxy_pass http://127.0.0.1:8200;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}sudo apt install -y nginx certbot python3-certbot-nginx
sudo nano /etc/nginx/sites-available/vault
sudo ln -s /etc/nginx/sites-available/vault /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d vault.example.net
curl -s https://vault.example.net/v1/sys/health | head -c 200; echoThe health endpoint returns JSON with "sealed":false when everything works. With Caddy, the site block is just the hostname and reverse_proxy 127.0.0.1:8200, and the Caddy tutorial shows the rest. Open the firewall for 80 and 443 only; port 8200 stays private.
How do you back up and upgrade Vault?
Take Raft snapshots on a schedule and upgrade through the package manager, reading the release notes for each minor version you cross.
vault operator raft snapshot save /root/vault-$(date +%F).snap
sudo apt update && sudo apt install --only-upgrade vault
sudo systemctl restart vault
vault statusThe snapshot needs a token with the right policy and is encrypted with the same keys, so the unseal keys are still required to use it on a new server. Copy snapshots off the machine, for example with restic as shown in daily backups. After every restart you unseal again; plan who does that before you schedule maintenance.
What are the usual problems?
- "Vault is sealed" after a reboot: expected. Enter the threshold of unseal keys.
- Permission denied on the data path:
/opt/vault/datamust be owned byvault:vault. - UI loads, API calls fail:
api_addrstill points at an old hostname, or the proxy drops theX-Vault-Tokenheader (a second proxy in the chain is the usual cause). - "no handler for route": the secrets engine is not mounted at that path; list mounts with
vault secrets list.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about HashiCorp Vault secrets server
Can Vault unseal itself automatically?
Auto-unseal exists, but it relies on an external key service or an HSM to hold the root key. On a single self-hosted server the manual Shamir keys described here are the simplest safe choice.
Is one node enough?
For one team or a handful of applications, yes. Raft can grow to three or five nodes later for availability; each node is a separate server with its own unseal step.
Does Vault send email?
No. Vault has no mail feature, so port 25 does not matter here. Alerts about Vault health come from your monitoring tool, which can send through an authenticated relay on port 587.
What happens if I lose the unseal keys?
The encrypted data cannot be recovered. Keep the five keys in separate safe places and test an unseal after storing them.
Should I use Vault or OpenBao?
Both use the same commands, API and concepts. Choose by licence and features: OpenBao is MPL 2.0, Vault is BSL 1.1 with features that appeared after the fork.
More in Self-hosted apps
- Nextcloud on Nginx
- ownCloud Infinite Scale
- Seafile file sync
- Vaultwarden password vault
- Passbolt team password manager
- Gitea Git hosting
- Forgejo Git server
- GitLab Community Edition
- Gogs Git service
- Wiki.js
- BookStack documentation
- Outline knowledge base
- Paperless-ngx documents
- n8n workflow automation
- Activepieces automation
- Plausible Analytics (Community Edition)
- Umami analytics
- Mattermost team chat
- Matrix Synapse with Element
- Jitsi Meet video calls
- ONLYOFFICE Docs with Nextcloud
- OpenBao secrets management
- Infisical secrets manager
- Authelia SSO and forward auth
- Zitadel identity platform
- VS Code in the browser (code-server)
- Joplin Server for notes sync
- Firefly III personal finance
- Snipe-IT asset tracking
- Odoo ERP on Ubuntu or Debian
- ERPNext with frappe_docker
- Dolibarr ERP and CRM with Nginx
- Penpot design tool with Docker
- Planka kanban boards
- Leantime project management
- Wekan boards with Docker
- Cal.com scheduling
- Chatwoot support inbox
- Mautic marketing automation
- DocuSeal document signing
- Metabase dashboards
- Appwrite backend server
- Self-hosted Supabase
- PocketBase backend
- RustDesk relay server
- Traccar GPS tracking
- Redmine project tracker
- The Lounge IRC client
- CyberChef data toolbox
- Typebot chat forms
- AFFiNE workspace
- Overleaf Community Edition
- Neko shared virtual browser
- imgproxy image resizing
- NetBox network inventory
- UVdesk help desk
- YetiForce CRM