Skip to content

Instantly share code, notes, and snippets.

@sturman
Forked from tetchel/argo-set-pw
Created October 19, 2020 14:39
Show Gist options
  • Save sturman/9d585e04bd9870d0a60e27b61cf3814a to your computer and use it in GitHub Desktop.
Save sturman/9d585e04bd9870d0a60e27b61cf3814a to your computer and use it in GitHub Desktop.
update password for argocd user
#!/usr/bin/env bash
# https://argoproj.github.io/argo-cd/faq/#i-forgot-the-admin-password-how-do-i-reset-it
username=$1
password=$2
if [[ -z $username || -z $password ]]; then
echo "Usage: $0 \$username \$password"
echo "Missing username or password argument"
exit 1
fi
bcrypted=$(htpasswd -nbBC 10 ${username} ${password})
bcrypted_pass=${bcrypted#*:}
date=$(date +%FT%T%Z)
echo 'Updating password for "'${username}'" to "'${password}'" at '${date}''
set -x
kubectl -n argocd patch secret argocd-secret -p '{"stringData" : { "'${username}.password'": "'${bcrypted_pass}'", "'${username}'.passwordMtime": "'${date}'" }}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment