Skip to content

Instantly share code, notes, and snippets.

@mbentley
Created November 2, 2017 13:53
Show Gist options
  • Save mbentley/7ff3d2b3487001d538be43f6be1a4195 to your computer and use it in GitHub Desktop.
Save mbentley/7ff3d2b3487001d538be43f6be1a4195 to your computer and use it in GitHub Desktop.
Remove all UCP bundles for a user
#!/bin/bash
set -e
USERNAME=""
PASSWORD=""
UCP_FQDN=""
AUTH_TOKEN="$(curl -sk -d '{"username":"'${USERNAME}'","password":"'${PASSWORD}'"}' "https://${UCP_FQDN}/auth/login" | jq -r .auth_token 2>/dev/null)"
CURL_OPTS=(-ks --header "Content-Type: application/json" --header "Accept: application/json" -H "Authorization: Bearer ${AUTH_TOKEN}")
BUNDLE_IDS="$(curl "${CURL_OPTS[@]}" "https://${UCP_FQDN}/accounts/${USERNAME}/publicKeys?limit=65000" | jq -r '.accountPublicKeys|.[]|.id')"
for ID in ${BUNDLE_IDS}
do
echo "Deleting client bundle ${ID}..."
curl -X DELETE "${CURL_OPTS[@]}" "https://${UCP_FQDN}/accounts/${USERNAME}/publicKeys/${ID}"
echo -e "done.\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment