Guest User

Untitled

a guest
Apr 20th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #!/bin/sh
  2. # Script for rotating passwords on the local machine.
  3. # Make sure and store VAULT_TOKEN as an environment variable before running this.
  4.  
  5. USERNAME=$1
  6. PASSLENGTH=$2
  7. VAULTURL=$3
  8. NEWPASS=$(openssl rand -base64 $PASSLENGTH)
  9. JSON="{ \"data\": { \"root\": \"$NEWPASS\" } }"
  10.  
  11. # First commit the new password to vault
  12. curl -H "X-Vault-Token: $VAULT_TOKEN" -X POST --data "$JSON" $VAULTURL/v1/secret/data/linux/$(hostname)_rootpw
  13.  
  14. # Then set it on the local machine
  15. echo $NEWPASS | passwd root --stdin
Add Comment
Please, Sign In to add comment