How to use MFA with AWS CLI?

前端 未结 13 1343
太阳男子
太阳男子 2020-12-05 00:05

How do I type in the MFA code when using the AWS CLI? I have checked the documentation page of IAM http://docs.aws.amazon.com/cli/latest/reference/iam/index.html.

I

13条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 00:38

    My use-case is I have a root account where all IAM users are created and assigned to IAM groups which in turn have the capability to assume roles on a different account with varying degree of access depending on the group they are on. I have a few house rules in place;

    1. No one is allowed to do anything on the root account except to manage their own IAM Users account.
    2. Required password reset.
    3. Required MFA.
    4. You cannot switch accounts without logging in with MFA.

    This has been set up using AWS Shared Organizations.

    Previously, I've been using a python script I wrote to let my users to login via cli with MFA and switch accounts. This is done by manipulating the ~/.aws/credentials.

    I've since migrated to using this project https://gitlab.com/severity1/aws-auth, which is written in Go and allows me to do the same without much setup and it works on windows, macosx and linux.

    This effectively gives all my users the ability to do local testing while developing Apps for AWS without having to hardcode AWS Credentials into their code.

提交回复
热议问题