Skip to content

Instantly share code, notes, and snippets.

@sriedel
Last active January 9, 2019 11:37
Show Gist options
  • Save sriedel/d95dda65ae877ea88f499f5e3d322954 to your computer and use it in GitHub Desktop.
Save sriedel/d95dda65ae877ea88f499f5e3d322954 to your computer and use it in GitHub Desktop.
Automate vault access
#!/usr/bin/bash
VAULT_USER=sr
SSH_SOCKET=$HOME/.ssh/control/vault
REMOTE_HOST=app1.staging.givve.io
VAULT_HOST=vault.givve.io
export VAULT_ADDR="https://$VAULT_HOST:8200"
export VAULT_CACERT="/home/sr/src/givve/givve/config/certs/vault_cacert.pem"
ssh -M -S $SSH_SOCKET -fNT -L 8200:$VAULT_HOST:8200 $REMOTE_HOST
vault status
vault login -method=userpass username=$VAULT_USER
bash
ssh -S $SSH_SOCKET -O exit $REMOTE_HOST
unset VAULT_ADDR
unset VAULT_CACERT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment