Created
December 30, 2014 20:02
-
-
Save davedash/d367701b9e526b040589 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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