SlideShare a Scribd company logo
HashiCorp's Vault
The Examples
Introduction
HashiCorp's Vault - The Examples
Basics Concepts
Vault is a "simple" HTTP service
How to make secrets secure?
● encryption
● renewing
● revoking
How to make secrets secure?
● encryption
● renewing
● revoking
How to make secrets secure?
● encryption
● renewing
● revoking
How to make secrets secure?
● encryption
● renewing
● revoking
How to make secrets secure?
● encryption
● renewing
● revoking
"Install" Vault
Do you know PGP?
keybase.io?
Download Vault
./scripts/download
Download Vault
# Download the 64bit binary
curl -Os "https://releases.hashicorp.com/vault/${vault_version}/vault_${vault_version}_linux_amd64.zip"
# Download checksums and signature
curl -Os "https://releases.hashicorp.com/vault/${vault_version}/vault_${vault_version}_SHA256SUMS"
curl -Os "https://releases.hashicorp.com/vault/${vault_version}/vault_${vault_version}_SHA256SUMS.sig"
# Import the hashicorp public key
curl "https://keybase.io/hashicorp/pgp_keys.asc" | gpg --import
Sample link: https://releases.hashicorp.com/vault/0.6.4/
Download Vault
# Verify the signature file is untampered.
$ gpg2 --options $project_directory/.gnupg/gpg.conf 
--verify "vault_${vault_version}_SHA256SUMS.sig" "vault_${vault_version}_SHA256SUMS"
# Verify the SHASUM matches the binary
$ cat "vault_${vault_version}_SHA256SUMS" 
| grep "vault_${vault_version}_linux_amd64.zip" 
| shasum -a 256 -c -
Download Vault
# Install Vault
$ unzip "vault_${vault_version}_linux_amd64.zip"
Download Vault
$ ./scripts/vault version
Vault v0.6.4 ('f4adc7fa960ed8e828f94bc6785bcdbae8d1b263')
Add Vault to $PATH
$ export PATH=$PATH:$PWD/scripts
Boot Vault
Vault in development
Vault development configuration
$ cat configuration/development.hcl
backend "file" {
path = "data"
}
listener "tcp" {
address = "127.0.0.1:8200"
tls_disable = 1
}
default_lease_ttl = "1h"
max_lease_ttl = "2h"
disable_mlock = true
Start Vault Server
$ vault server -config=$PWD/configuration/development.hcl
Initialize Vault
$ vault init -key-shares=1 -key-threshold=1
Unseal Vault Server
$ vault unseal 4e02850adda5af588e290592d11d323fa1ce...
Vault in production
PostgreSQL Backend
HashiCorp's Vault - The Examples
Docker Compose Configuration
$ cat .env.db
POSTGRES_USER=vault
POSTGRES_PASSWORD=vault
POSTGRES_DB=vault
Docker Compose Configuration
$ cat docker-compose.yml
---
version: '2'
services:
db:
image: "postgres:9.5.4"
hostname: db
env_file:
- .env.db
ports:
- "9191:5432"
Start PostgreSQL
$ docker-compose ps
Name Command State Ports
----------------------------------------------------------------------------
vault_db_1 /docker-entrypoint.sh postgres Up 0.0.0.0:9191->5432/tcp
$ docker-compose up -d
Mount the PostgreSQL backend
$ vault mount -path=postgresql-test 
-default-lease-ttl=30m 
-max-lease-ttl=12h 
Postgresql
Successfully mounted 'postgresql' at 'postgresql-test'!
Verify the PostgreSQL backend
$ vault mounts | head -n1 && vault mounts | grep postgresql
Path Type Default TTL Max TTL Description
postgresql-test/ postgresql 1800 43200
Establish connection between
PostgreSQL and Vault
$ source .env.db
$ vault write postgresql-test/config/connection 
connection_url="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@0.0.0.0:9191
/${POSTGRES_DB}?sslmode=disable"
Tell Vault how
to create PostgreSQL users
SQL query in readable format
CREATE ROLE "{{name}}" WITH LOGIN PASSWORD "{{password}}"
VALID UNTIL "{{expiration}}";
GRANT SELECT ON ALL TABLES IN SCHEMA public TO "{{name}}";
Tell Vault how
to create PostgreSQL users
$ vault write postgresql-test/roles/readonly 
sql="CREATE ROLE "{{name}}" WITH LOGIN PASSWORD '{{password}}' VALID
UNTIL '{{expiration}}';
GRANT SELECT ON ALL TABLES IN SCHEMA public TO "{{name}}";"
Success! Data written to: postgresql-test/roles/readonly
Generate user with password
$ vault read -format=json 
postgresql-test/creds/readonly 
| tee postgresql-user-credentials.json 
| jq .
{
"request_id": "b02b0a7f-9ea1-34f0-59fb-b25015114f5c",
"lease_id":
"postgresql-test/creds/readonly/40ff9937-8e6b-41c4-26c4-67e5c2be3024",
"lease_duration": 3600,
"renewable": true,
"data": {
"password": "130a6869-9e1a-94aa-c4ce-88bd5d7cc93e",
"username": "root-42e196da-4b70-47cd-cc72-01fd791cdd84"
},
"warnings": null
}
user with password - result
Connect to PostgreSQL
$ username=$(jq -r .data.username postgresql-user-credentials.json)
$ password=$(jq -r .data.password postgresql-user-credentials.json)
$ docker run --rm -it 
--link=vault_db_1:db 
--net vault_default 
--env PGPASSWORD="${password}" 
--env username="${username}" 
--env POSTGRES_DB="${POSTGRES_DB}" 
postgres:9.5.4 bash
> psql --host=db --username="${username}" "${POSTGRES_DB}"
Connect to PostgreSQL
> SELECT datname AS database,
usename AS user
FROM pg_stat_activity
WHERE state = 'active';
database | user
---------+-------------------------------------------
vault | root-45fb7d50-c99f-dd78-f3c5-e20b9636a300
(1 row)
user with password
SSH Backend
Overview

More Related Content

PPTX
Hashicorp Vault ppt
PDF
Vault
PPTX
Vault - Secret and Key Management
PDF
Hashicorp Vault: Open Source Secrets Management at #OPEN18
PDF
Introducing Vault
PDF
Chickens & Eggs: Managing secrets in AWS with Hashicorp Vault
PDF
Introduction to Vault
PDF
Neil Saunders (Beamly) - Securing your AWS Infrastructure with Hashicorp Vault
Hashicorp Vault ppt
Vault
Vault - Secret and Key Management
Hashicorp Vault: Open Source Secrets Management at #OPEN18
Introducing Vault
Chickens & Eggs: Managing secrets in AWS with Hashicorp Vault
Introduction to Vault
Neil Saunders (Beamly) - Securing your AWS Infrastructure with Hashicorp Vault

What's hot (20)

PDF
Secret Management with Hashicorp’s Vault
PDF
Vault 101
PDF
Credential store using HashiCorp Vault
PPTX
Keeping a Secret with HashiCorp Vault
PDF
Adopting HashiCorp Vault
PPTX
Secret Management with Hashicorp Vault and Consul on Kubernetes
PDF
Overview of secret management solutions and architecture
PDF
Carlos García - Pentesting Active Directory Forests [rooted2019]
PDF
Using Vault to decouple MySQL Secrets
PDF
HashiCorp Vault configuration as code via HashiCorp Terraform- stories from t...
PDF
Kubernetes Security Best Practices - With tips for the CKS exam
PPTX
(Ab)Using GPOs for Active Directory Pwnage
PDF
OpenID Connect Explained
PDF
Kubernetes security
PPTX
OAuth2 + API Security
PDF
Kubernetes Secrets Management on Production with Demo
PDF
Welcome to the Jungle: Pentesting AWS
PPTX
API Security : Patterns and Practices
PDF
Introduction to GitHub Actions
PPTX
Abusing Microsoft Kerberos - Sorry you guys don't get it
Secret Management with Hashicorp’s Vault
Vault 101
Credential store using HashiCorp Vault
Keeping a Secret with HashiCorp Vault
Adopting HashiCorp Vault
Secret Management with Hashicorp Vault and Consul on Kubernetes
Overview of secret management solutions and architecture
Carlos García - Pentesting Active Directory Forests [rooted2019]
Using Vault to decouple MySQL Secrets
HashiCorp Vault configuration as code via HashiCorp Terraform- stories from t...
Kubernetes Security Best Practices - With tips for the CKS exam
(Ab)Using GPOs for Active Directory Pwnage
OpenID Connect Explained
Kubernetes security
OAuth2 + API Security
Kubernetes Secrets Management on Production with Demo
Welcome to the Jungle: Pentesting AWS
API Security : Patterns and Practices
Introduction to GitHub Actions
Abusing Microsoft Kerberos - Sorry you guys don't get it
Ad

Similar to HashiCorp's Vault - The Examples (20)

PPTX
Running Docker in Development & Production (#ndcoslo 2015)
PDF
Null Bachaav - May 07 Attack Monitoring workshop.
PDF
Continuous Delivery: The Next Frontier
PDF
[Devconf.cz][2017] Understanding OpenShift Security Context Constraints
PDF
Kafka security ssl
PDF
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
DOC
X64服务器 lnmp服务器部署标准 new
PPTX
Docker Security workshop slides
ODP
PHP London Dec 2013 - Varnish - The 9 circles of hell
PDF
Keep it simple web development stack
PDF
AWS Study Group - Chapter 03 - Elasticity and Scalability Concepts [Solution ...
PPTX
Start tracking your ruby infrastructure
PDF
Into The Box 2018 Going live with commandbox and docker
PDF
Going live with BommandBox and docker Into The Box 2018
PDF
Django로 만든 웹 애플리케이션 도커라이징하기 + 도커 컴포즈로 개발 환경 구축하기
PDF
Salesforce at Stacki Atlanta Meetup February 2016
PDF
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
PPTX
How To Securely Set Up Shipyard 2.0.10 with TLS on CoreOS
DOCX
Install elasticsearch, logstash and kibana
PDF
Postgres the hardway
Running Docker in Development & Production (#ndcoslo 2015)
Null Bachaav - May 07 Attack Monitoring workshop.
Continuous Delivery: The Next Frontier
[Devconf.cz][2017] Understanding OpenShift Security Context Constraints
Kafka security ssl
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
X64服务器 lnmp服务器部署标准 new
Docker Security workshop slides
PHP London Dec 2013 - Varnish - The 9 circles of hell
Keep it simple web development stack
AWS Study Group - Chapter 03 - Elasticity and Scalability Concepts [Solution ...
Start tracking your ruby infrastructure
Into The Box 2018 Going live with commandbox and docker
Going live with BommandBox and docker Into The Box 2018
Django로 만든 웹 애플리케이션 도커라이징하기 + 도커 컴포즈로 개발 환경 구축하기
Salesforce at Stacki Atlanta Meetup February 2016
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
How To Securely Set Up Shipyard 2.0.10 with TLS on CoreOS
Install elasticsearch, logstash and kibana
Postgres the hardway
Ad

Recently uploaded (20)

PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPT
Teaching material agriculture food technology
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
KodekX | Application Modernization Development
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Chapter 3 Spatial Domain Image Processing.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Review of recent advances in non-invasive hemoglobin estimation
Teaching material agriculture food technology
The AUB Centre for AI in Media Proposal.docx
Advanced methodologies resolving dimensionality complications for autism neur...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Dropbox Q2 2025 Financial Results & Investor Presentation
KodekX | Application Modernization Development
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Reach Out and Touch Someone: Haptics and Empathic Computing
Mobile App Security Testing_ A Comprehensive Guide.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Unlocking AI with Model Context Protocol (MCP)
Diabetes mellitus diagnosis method based random forest with bat algorithm
Encapsulation_ Review paper, used for researhc scholars
Chapter 3 Spatial Domain Image Processing.pdf

HashiCorp's Vault - The Examples

  • 5. Vault is a "simple" HTTP service
  • 6. How to make secrets secure? ● encryption ● renewing ● revoking
  • 7. How to make secrets secure? ● encryption ● renewing ● revoking
  • 8. How to make secrets secure? ● encryption ● renewing ● revoking
  • 9. How to make secrets secure? ● encryption ● renewing ● revoking
  • 10. How to make secrets secure? ● encryption ● renewing ● revoking
  • 12. Do you know PGP? keybase.io?
  • 14. Download Vault # Download the 64bit binary curl -Os "https://releases.hashicorp.com/vault/${vault_version}/vault_${vault_version}_linux_amd64.zip" # Download checksums and signature curl -Os "https://releases.hashicorp.com/vault/${vault_version}/vault_${vault_version}_SHA256SUMS" curl -Os "https://releases.hashicorp.com/vault/${vault_version}/vault_${vault_version}_SHA256SUMS.sig" # Import the hashicorp public key curl "https://keybase.io/hashicorp/pgp_keys.asc" | gpg --import Sample link: https://releases.hashicorp.com/vault/0.6.4/
  • 15. Download Vault # Verify the signature file is untampered. $ gpg2 --options $project_directory/.gnupg/gpg.conf --verify "vault_${vault_version}_SHA256SUMS.sig" "vault_${vault_version}_SHA256SUMS" # Verify the SHASUM matches the binary $ cat "vault_${vault_version}_SHA256SUMS" | grep "vault_${vault_version}_linux_amd64.zip" | shasum -a 256 -c -
  • 16. Download Vault # Install Vault $ unzip "vault_${vault_version}_linux_amd64.zip"
  • 17. Download Vault $ ./scripts/vault version Vault v0.6.4 ('f4adc7fa960ed8e828f94bc6785bcdbae8d1b263')
  • 18. Add Vault to $PATH $ export PATH=$PATH:$PWD/scripts
  • 21. Vault development configuration $ cat configuration/development.hcl backend "file" { path = "data" } listener "tcp" { address = "127.0.0.1:8200" tls_disable = 1 } default_lease_ttl = "1h" max_lease_ttl = "2h" disable_mlock = true
  • 22. Start Vault Server $ vault server -config=$PWD/configuration/development.hcl
  • 23. Initialize Vault $ vault init -key-shares=1 -key-threshold=1
  • 24. Unseal Vault Server $ vault unseal 4e02850adda5af588e290592d11d323fa1ce...
  • 28. Docker Compose Configuration $ cat .env.db POSTGRES_USER=vault POSTGRES_PASSWORD=vault POSTGRES_DB=vault
  • 29. Docker Compose Configuration $ cat docker-compose.yml --- version: '2' services: db: image: "postgres:9.5.4" hostname: db env_file: - .env.db ports: - "9191:5432"
  • 30. Start PostgreSQL $ docker-compose ps Name Command State Ports ---------------------------------------------------------------------------- vault_db_1 /docker-entrypoint.sh postgres Up 0.0.0.0:9191->5432/tcp $ docker-compose up -d
  • 31. Mount the PostgreSQL backend $ vault mount -path=postgresql-test -default-lease-ttl=30m -max-lease-ttl=12h Postgresql Successfully mounted 'postgresql' at 'postgresql-test'!
  • 32. Verify the PostgreSQL backend $ vault mounts | head -n1 && vault mounts | grep postgresql Path Type Default TTL Max TTL Description postgresql-test/ postgresql 1800 43200
  • 33. Establish connection between PostgreSQL and Vault $ source .env.db $ vault write postgresql-test/config/connection connection_url="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@0.0.0.0:9191 /${POSTGRES_DB}?sslmode=disable"
  • 34. Tell Vault how to create PostgreSQL users SQL query in readable format CREATE ROLE "{{name}}" WITH LOGIN PASSWORD "{{password}}" VALID UNTIL "{{expiration}}"; GRANT SELECT ON ALL TABLES IN SCHEMA public TO "{{name}}";
  • 35. Tell Vault how to create PostgreSQL users $ vault write postgresql-test/roles/readonly sql="CREATE ROLE "{{name}}" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}'; GRANT SELECT ON ALL TABLES IN SCHEMA public TO "{{name}}";" Success! Data written to: postgresql-test/roles/readonly
  • 36. Generate user with password $ vault read -format=json postgresql-test/creds/readonly | tee postgresql-user-credentials.json | jq .
  • 37. { "request_id": "b02b0a7f-9ea1-34f0-59fb-b25015114f5c", "lease_id": "postgresql-test/creds/readonly/40ff9937-8e6b-41c4-26c4-67e5c2be3024", "lease_duration": 3600, "renewable": true, "data": { "password": "130a6869-9e1a-94aa-c4ce-88bd5d7cc93e", "username": "root-42e196da-4b70-47cd-cc72-01fd791cdd84" }, "warnings": null } user with password - result
  • 38. Connect to PostgreSQL $ username=$(jq -r .data.username postgresql-user-credentials.json) $ password=$(jq -r .data.password postgresql-user-credentials.json)
  • 39. $ docker run --rm -it --link=vault_db_1:db --net vault_default --env PGPASSWORD="${password}" --env username="${username}" --env POSTGRES_DB="${POSTGRES_DB}" postgres:9.5.4 bash > psql --host=db --username="${username}" "${POSTGRES_DB}" Connect to PostgreSQL
  • 40. > SELECT datname AS database, usename AS user FROM pg_stat_activity WHERE state = 'active'; database | user ---------+------------------------------------------- vault | root-45fb7d50-c99f-dd78-f3c5-e20b9636a300 (1 row) user with password