This is shell helper for you to use MFA token to authenticate access AWS resources with the AWS Command Line Interface (AWS CLI).
- AWS CLI
- AWS account ready and you already have a pair of
aws_access_key_id
/aws_secret_access_key
ready
Run aws configure
to set your permanent aws_access_key_id
/ aws_secret_access_key
pair into a profile.
aws configure --profile normal-profile
And follow the instruction on screen.
Next step is to clone this repo. and copy .config.example
to .config
cp .config.example .config
And made changes accordingly. For the ARN_OF_MFA
, login to AWS console. IAM > Users > your account > security credentials > Assigned MFA device.
Find your AWS MFA token and run the following.
./aws-sts-token-helper.sh -t 123456
Your AWS profile will be updated accordingly. So you can try the following to see if it work:
aws --profile profile-with-mfa s3 ls
Script only tested under macos. Not sure if it work on Linux platform.
cp .env.example .env
make && ./aws-sts-token-helper -t 123456