Vault: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
| (3 intermediate revisions by the same user not shown) | |||
| Line 47: | Line 47: | ||
|- | |- | ||
|valign='top' style='width:50%'| | |valign='top' style='width:50%'| | ||
<syntaxhighlight lang='bash'> | |||
# Enabled approle auth method | |||
vault auth enable approle | |||
</syntaxhighlight> | |||
|valign='top' style='width:50%'| | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
# Enabled userpass auth method | # Enabled userpass auth method | ||
| Line 52: | Line 60: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|valign='top | |valign='top'| | ||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
# Enabled kubernetes auth method | # Enabled kubernetes auth method | ||
| Line 59: | Line 67: | ||
|- | |- | ||
|valign='top' colspan='2'| | |valign='top' colspan='2'| | ||
{|class='wikitable mw-collapsible mw-collapsed' | |||
!scope='col' style='text-align:left' colspan='2'| Auth » Approle | |||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight lang='bash'> | |||
cat <<'INI' | vault policy write policy-shahed-ab-eso-app - | |||
# Mount : shahed/academia/dev | |||
# Secret: audit | |||
path "shahed/academia/dev/data/audit" { | |||
capabilities = ["read"] | |||
} | |||
INI | |||
vault policy read policy-shahed-ab-eso-app | |||
</syntaxhighlight> | |||
<syntaxhighlight lang='bash'> | |||
vault write auth/approle/role/role-shahed-ab-eso-app \ | |||
token_policies=policy-shahed-ab-eso-app token_ttl=1h token_max_ttl=3h | |||
</syntaxhighlight> | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight lang='bash'> | |||
vault policy read policy-shahed-ab-eso-app | |||
vault read auth/approle/role/role-shahed-ab-eso-app | |||
vault read auth/approle/role/role-shahed-ab-eso-app/role-id | |||
</syntaxhighlight> | |||
<syntaxhighlight lang='bash'> | |||
vault list auth/approle/role/role-shahed-ab-eso-app/secret-id | |||
vault write -f auth/approle/role/role-shahed-ab-eso-app/secret-id | |||
</syntaxhighlight> | |||
<syntaxhighlight lang='bash'> | |||
vault list auth/approle/role/role-shahed-ab-eso-app/secret-id | |||
vault write auth/approle/role/role-shahed-ab-eso-app/secret-id/destroy \ | |||
secret_id=26701c33-1362-e744-6b2a-c28250b3ee64 | |||
</syntaxhighlight> | |||
|} | |||
{|class='wikitable mw-collapsible mw-collapsed' | {|class='wikitable mw-collapsible mw-collapsed' | ||
!scope='col' style='text-align:left' colspan='2'| Auth » Userpass | !scope='col' style='text-align:left' colspan='2'| Auth » Userpass | ||
| Line 96: | Line 140: | ||
|} | |} | ||
{|class='wikitable mw-collapsible mw-collapsed' | {|class='wikitable mw-collapsible mw-collapsed' | ||
!scope='col' style='text-align:left' colspan='2'| Auth » Kubernetes | !scope='col' style='text-align:left' colspan='2'| Auth » Kubernetes » VSO | ||
|- | |- | ||
|valign='top' style='width:50%'| | |valign='top' style='width:50%'| | ||
| Line 161: | Line 178: | ||
|} | |} | ||
{|class='wikitable mw-collapsible' | {|class='wikitable mw-collapsible' | ||
!scope='col' style='text-align:left' colspan='2'| Auth » Kubernetes | !scope='col' style='text-align:left' colspan='2'| Auth » Kubernetes » ESO | ||
|- | |- | ||
|valign='top' style='width:50%'| | |valign='top' style='width:50%'| | ||
| Line 196: | Line 213: | ||
vault read auth/kubernetes/role/role-shahed-ab-eso | vault read auth/kubernetes/role/role-shahed-ab-eso | ||
</syntaxhighlight> | |||
|} | |||
{|class='wikitable mw-collapsible mw-collapsed' | |||
!scope='col' style='text-align:left' colspan='2'| Auth » Kubernetes » shahed-ab | |||
|- | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight lang='bash'> | |||
cat ${HOME}/.kube/shahed-ab-kubeconfig.yaml \ | |||
| yq -r '.clusters[0].cluster.certificate-authority-data'|base64 -d | |||
export KUBECONFIG="${HOME}/.kube/shahed-ab-kubeconfig.yaml" | |||
kubectl get --raw /.well-known/openid-configuration|yq -P | |||
kubectl get service kubernetes -n default | |||
kubectl cluster-info | |||
</syntaxhighlight> | |||
|valign='top' style='width:50%'| | |||
<syntaxhighlight lang='bash'> | |||
vault auth enable -path='k8s/shahed/ab' kubernetes | |||
cat ${HOME}/.kube/shahed-ab-kubeconfig.yaml \ | |||
| yq -r '.clusters[0].cluster.certificate-authority-data'|base64 -d \ | |||
| vault write auth/k8s/shahed/ab/config kubernetes_host='https://10.20.40.2:8443' \ | |||
kubernetes_ca_cert=@/dev/stdin disable_local_ca_jwt='true' | |||
vault read auth/k8s/shahed/ab/config | |||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |} | ||
Latest revision as of 07:40, 24 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.40aTe1S58DWIstRk4bHPgESg'
export VAULT_ADDR='https://vault.shahed.biz.ops'
vault status
|
export VAULT_SKIP_VERIFY=true
export VAULT_FORMAT=yaml
vault login
|
Auth
|
Auth | |||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
# Enabled approle auth method
vault auth enable approle
|
|||||||||||||||||||||||||||||||||
# Enabled userpass auth method
vault auth enable userpass
|
# Enabled kubernetes auth method
vault auth enable kubernetes
| ||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||
vault auth disable userpass
vault auth list
|
vault auth disable k8s/shahed/ab
vault auth disable kubernetes
| ||||||||||||||||||||||||||||||||
Engine » KV
|
Engine » KV | |||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||
Engine » DB
|
Engine » DB | |||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
# Enabled the database secrets engine
vault secrets enable database
|
|||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||
Token » Init
|
Token » Init | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||
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'
|
# self destructive or dangerous
vault token revoke -self
|
|
References
|
References | ||
|---|---|---|