Bootstrap FreeKB - Amazon Web Services (AWS) - List IAM Multi Factor Authentication (MFA) Devices using the AWS CLI
Amazon Web Services (AWS) - List IAM Multi Factor Authentication (MFA) Devices using the AWS CLI


This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.

IAM (Identity and Access Management) contains non-root users that have been permitted to perform certain actions. IAM can be setup with Multi-Factor Authentication (MFA). For example, a users mobile phone can be added so that the user must first authenticate with their username and password (something they know) and must next authenticate with an authentication code from their MFA device (something they have). The Microsoft Authenticator app is one such app that could be used to authenticate.

 

The aws iam list-virtual-mfa-devices command can be used to list the IAM multi-factor authentication devices that have been added.

aws iam list-virtual-mfa-devices

 

If no devices have been added, an empty list will be returned.

{
    "VirtualMFADevices": []
}

 

If an MFA device has been assigned but not yet linked to a user, something like this will be returned.

{
    "VirtualMFADevices": [
        {
            "SerialNumber": "arn:aws:iam::123456789012:mfa/MyMFADevice"
        }
    ]
}

 

On the other hand, if a device has been assigned and linked to a user, something like this should be returned.

{
    "VirtualMFADevices": [
        {
            "SerialNumber": "arn:aws:iam::713441234252:mfa/JohnsCellPhone",
            "User": {
                "Path": "/",
                "UserName": "johndoe",
                "UserId": "AIDA1234L76GABCDB2123",
                "Arn": "arn:aws:iam::713441234252:user/jeremycanfield",
                "CreateDate": "2022-09-13T11:13:03+00:00"
            },
            "EnableDate": "2023-06-14T01:52:35+00:00"
        }
    ]
}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 1b07d4 in the box below so that we can be sure you are a human.