You are here:>>>Configure Multi-Factor Authentication (MFA) with AWS CLI

Configure Multi-Factor Authentication (MFA) with AWS CLI

Video Tutorial

In this blog I will show you how to configure MFA with AWS CLI. Please watch the video for detailed explanation and demo.

GenerateMFASecurityToken Shell Script

Generate Security Token Process

  • Make sure AWS CLI is installed and configured. This can be your local laptop/desktop or AWS EC2 instance.
  • Copy script to the machine where AWSCLI is installed and configured.
  • Execute with MFA Profile Name and Base Profile Name as arguments.
    • default-mfa : New profile created and saved in ~/.aws/credentials & ~/.aws/config
    • default : Existing profile configured with AWS AccessID and SecretAccessKey and saved in ~/.aws/credentials & ~/.aws/config

  • Provide token code from your MFA device when prompted
  • Make sure default-mfa profile is created in ~/.aws/credentials & ~/.aws/config
  • Test AWS CLI commands using new profile

That’s all folks! You now know how to configure Multi Factor Authentication with AWSCLI. If you have any questions or suggestions, please post in the comments section.


About the Author:

I am a Senior Cloud Professional specialized in AWS Cloud with 11 years of IT experience. I am enthusiastic about Serverless Architecture. I am an expert in Oracle Fusion Middleware.

Leave A Comment