Skip to content

Instantly share code, notes, and snippets.

@davedash
Created December 30, 2014 20:02
Show Gist options
  • Save davedash/d367701b9e526b040589 to your computer and use it in GitHub Desktop.
Save davedash/d367701b9e526b040589 to your computer and use it in GitHub Desktop.
#!/bin/bash -e
# This script finds IAM users who have passwords but no MFA.
# Deal with them accordingly.
# Generate a report
aws iam generate-credential-report > /dev/null
# Download report.
REPORT=$(aws iam get-credential-report)
# Parse the good stuff from the JSON
DATA=$(echo ${REPORT}|jq ".Content" -r)
echo ${DATA} | \
# Decode the CSV
base64 --decode | \
# Look at PW enabled and MFA enabled fields
cut -d, -f1,4,8 | \
# Find people with PW but not MFA
grep "true,false$" | \
# Print their beautiful usernames
cut -d, -f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment