Vault: Difference between revisions
Jump to navigation
Jump to search
| Line 122: | Line 122: | ||
vault kv get shahed/academia/dev/pgsql | vault kv get shahed/academia/dev/pgsql | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |||
|} | |||
==Engine » Database== | |||
{|class='wikitable mw-collapsible' | |||
!scope='col' style='text-align:left' colspan='2'| | |||
Engine » Database | |||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight lang='bash'> | |||
# Enabled the database secrets engine | |||
vault secrets enable database | |||
</syntaxhighlight> | |||
|valign='top' style='width:50%'| | |||
|- | |||
|valign='top' colspan='2'| | |||
{|class='wikitable mw-collapsible' | |||
!scope='col' style='text-align:left' colspan='2'| | |||
Database » PostgreSQL | |||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight lang='bash'> | |||
vault write database/config/shahed-ab-psql \ | |||
plugin_name='postgresql-database-plugin' allowed_roles='vault' \ | |||
connection_url='postgresql://{{username}}:{{password}}@192.168.49.2:5432/shahed' \ | |||
username='shahed' password='sadaqah!' \ | |||
password_authentication='scram-sha-256' | |||
</syntaxhighlight> | |||
|valign='top' style='width:50%'| | |||
|- | |||
|valign='top' colspan='2'| | |||
<syntaxhighlight lang='bash'> | |||
vault write database/roles/shahed-ab-psql-academia db_name="shahed-ab-psql" \ | |||
creation_statements="CREATE ROLE \"{{name}}\" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}'; \ | |||
GRANT SELECT ON ALL TABLES IN SCHEMA public TO \"{{name}}\";" \ | |||
default_ttl="1h" \ | |||
max_ttl="24h" | |||
</syntaxhighlight> | |||
|} | |||
{|class='wikitable mw-collapsible mw-collapsed' | |||
!scope='col' style='text-align:left' colspan='2'| | |||
Database » MariaDB | |||
|- | |||
|valign='top' style='width:50%'| | |||
|valign='top' style='width:50%'| | |||
|} | |||
{|class='wikitable mw-collapsible mw-collapsed' | |||
!scope='col' style='text-align:left' colspan='2'| | |||
Database » Redis | |||
|- | |||
|valign='top' style='width:50%'| | |||
|valign='top' style='width:50%'| | |||
|} | |} | ||
|} | |} | ||
Revision as of 03:01, 21 January 2026
curl -fsSL https://apt.releases.hashicorp.com/gpg\
| sudo tee /etc/apt/keyrings/hashicorp.asc >/dev/null
DISTRIBUTION=$(. /etc/os-release && echo "${VERSION_CODENAME}")
cat << SRC | sudo tee /etc/apt/sources.list.d/hashicorp.list >/dev/null
deb [arch=$(dpkg --print-architecture)\
signed-by=/etc/apt/keyrings/hashicorp.asc]\
https://apt.releases.hashicorp.com ${DISTRIBUTION} main
SRC
|
cat <<'EXE' | sudo bash
apt-get update && apt-get install -y vault
systemctl disable --now vault.service
systemctl stop vault.service
systemctl mask vault.service
systemctl status vault.service
vault version
which vault
EXE
|
export VAULT_TOKEN='hvs.b613hrNQ25fJEkWqGB2KCWgl'
export VAULT_ADDR='https://vault.shahed.biz.ops'
vault status
|
export VAULT_SKIP_VERIFY=true
export VAULT_FORMAT=yaml
vault login
|
Engine » KV
|
Engine » KV | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||
Engine » Database
|
Engine » Database | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
# Enabled the database secrets engine
vault secrets enable database
|
|||||||||||||||
| |||||||||||||||
Playground
|
Playground | |
|---|---|
echo "$(cat /dev/urandom|tr -dc 'A-Za-z0-9'|head -c 40)"
echo "$(cat /dev/urandom|tr -dc 'A-Za-z0-9'|head -c 20)"
echo "$(cat /dev/urandom|tr -dc 'A-Za-z0-9'|head -c 16)"
echo "$(cat /dev/urandom|tr -dc 'A-Za-z0-9'|head -c 8)"
|
vault auth list
vault audit list
vault policy list
vault secrets list
|
vault operator init -key-shares=5 -key-threshold=3
vault token lookup
vault status
|
vault operator unseal '/bvRmLPLF8MnfOQQWrhdqAmLBSKfNtSSkcyWY/uXZ0+F'
vault operator unseal 'Jh5mA+DwX/zlU+3jvxlgNarSzAOBRHvNcF3QOoGtzl/h'
vault operator unseal 'DqUWoe6MN6oDKi3bYoZuXSbT0ZpT0/Pbg0kpTkhkUfVP'
|
References
|
References | ||
|---|---|---|