Last active
June 2, 2022 07:39
-
-
Save Mishco/6b04533ec8419212d36ac6c8092958e1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Start vault | |
vault server -config vault-test.hcl | |
# Export values | |
export VAULT_ADDR='https://0.0.0.0:8201' | |
export VAULT_SKIP_VERIFY='true' | |
# Parse unsealed keys | |
mapfile -t keyArray < <( grep "Unseal Key " < generated_keys.txt | cut -c15- ) | |
vault operator unseal ${keyArray[0]} | |
vault operator unseal ${keyArray[1]} | |
vault operator unseal ${keyArray[2]} | |
# Get root token | |
mapfile -t rootToken < <(grep "Initial Root Token: " < generated_keys.txt | cut -c21- ) | |
echo ${rootToken[0]} > root_token.txt | |
export VAULT_TOKEN=${rootToken[0]} | |
# Enable kv | |
vault secrets enable -version=1 kv | |
# Enable userpass and add default user | |
vault auth enable userpass | |
vault policy write spring-policy spring-policy.hcl | |
vault write auth/userpass/users/admin password=${SECRET_PASS} policies=spring-policy | |
# Add test value to my-secret | |
vault kv put kv/my-secret my-value=s3cr3t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment