Skip to content

Instantly share code, notes, and snippets.

@bashtoni
Created June 26, 2017 07:38
Show Gist options
  • Save bashtoni/1c7a542a97b7c9bb178b4645ac0de38e to your computer and use it in GitHub Desktop.
Save bashtoni/1c7a542a97b7c9bb178b4645ac0de38e to your computer and use it in GitHub Desktop.
Remove MFA for a user
#!/bin/bash
if [ -n $1 ]; then
echo "Usage: $0 <username>"
fi
for mfaserial in $(aws iam list-mfa-devices --user-name $user --query MFADevices[].SerialNumber --output text); do
aws iam deactivate-mfa-device --serial-number $mfaserial --user-name $user
aws iam delete-virtual-mfa-device --serial-number $mfaserial
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment