跳至内容

Force existing user to use MFA

0

Hello!
I have multiple users on IAM and I want to force them to use MFA.
Is there any policy I can create so that at the next login time AWS will force the MFA? I have already based on the following documentation and it does not have a positive result.

https://aws.amazon.com/pt/blogs/security/how-to-delegate-management-of-multi-factor-authentication-to-aws-iam-users/
https://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_users-self-manage-mfa-and-creds.html

已提问 5 年前1458 查看次数
2 回答
1

You can force IAM users have to enable MFA by using the following policy (e.g. named as "AllowOnlyMFA"):

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "BlockMostAccessUnlessSignedInWithMFA",
            "Effect": "Deny",
            "NotAction": [
                "iam:CreateVirtualMFADevice",
                "iam:DeleteVirtualMFADevice",
                "iam:ListVirtualMFADevices",
                "iam:EnableMFADevice",
                "iam:ResyncMFADevice",
                "iam:ListAccountAliases",
                "iam:ListUsers",
                "iam:ListSSHPublicKeys",
                "iam:ListAccessKeys",
                "iam:ListServiceSpecificCredentials",
                "iam:ListMFADevices",
                "iam:GetAccountSummary",
                "sts:GetSessionToken"
            ],
            "Resource": "*",
            "Condition": {
                "Bool": {
                    "aws:MultiFactorAuthPresent": "false",
                    "aws:ViaAWSService": "false"
                }
            }
        }
    ]
}

Then, you can attach this policy to a Group. After that, all the users (including existing or new) will be bound to this policy. You can also explicitly attach this policy to an existing user or specify it when creating a user.

Note that the user should have other normal policies attached as usual. For example, an IAM admin user will have "AdministratorAccess" attached plus this one.

Then, this new user logs in without MFA. He will not be able to do anything, e.g. shown with a lot of API errors when trying to access EC2 console.

Enter image description here

After that, the user can choose to enable MFA himself. After that, the user logs in again with MFA this time, and then the user will be able to perform all the admin functionalities.

Reference: https://aws.amazon.com/premiumsupport/knowledge-center/mfa-iam-user-aws-cli/

AWS
已回答 3 年前
0

Resolved

已回答 4 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。