How to use MFA with AWS CLI?

前端 未结 13 1341
太阳男子
太阳男子 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:41

    Step-by-step manual solution:

    1. Request a session token with MFA
    aws sts get-session-token --serial-number arn-of-the-mfa-device --token-code code-from-token
    

    arn-of-the-mfa-device: visible from your user IAM

    • Option: Use CLI to retrieve: aws iam list-mfa-devices --user-name ryan
    • Option: View in IAM console: IAM --> Users --> --> Security Credentials

    code-from-token: 6 digit code from your configured MFA device

    1. Create a profile with the returned credentials
    aws configure --profile cli
    
    aws configure set --profile mfa aws_session_token 
    

    aws_session_token is not included in aws configure

    1. Test command
    aws s3 ls --profile cli
    

提交回复
热议问题