Skip to content

Authenticate to AWS with MFA ๐Ÿ”

License

Notifications You must be signed in to change notification settings

jhandguy/aws-mfa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

30 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

aws-mfa

Version Downloads License Build Release

Authenticate to AWS with MFA ๐Ÿ”

โžœ aws-mfa -h
Authenticate to AWS with MFA ๐Ÿ”

Usage: aws-mfa [OPTIONS] --code <CODE> <HOME>

Arguments:
  <HOME>  Home directory containing the AWS hidden folder [env: HOME=/Users/JohnDoe]

Options:
  -r, --region <REGION>      Name of the AWS region [default: eu-west-1]
  -p, --profile <PROFILE>    Name of the AWS profile [default: default]
  -s, --suffix <SUFFIX>      Suffix of the original AWS profile [default: noauth]
  -c, --code <CODE>          MFA code
  -d, --duration <DURATION>  Session duration in seconds [default: 3600]
  -h, --help                 Print help information

Installation

aws-mfa is published on crates.io and can be installed with

cargo install aws-mfa

or downloaded as binary from the releases page.

Usage

Add basic credentials in ~/.aws/credentials:

[<profile_name>-noauth]
aws_access_key_id = <aws_access_key_id>
aws_secret_access_key = <aws_secret_access_key>

Note: make sure to add the -noauth suffix to the profile name

Run aws-mfa:

aws-mfa -p <profile_name> -c <mfa_code>

Check generated credentials in ~/.aws/credentials:

[<profile_name>]
aws_access_key_id = <aws_access_key_id>
aws_secret_access_key = <aws_secret_access_key>
aws_session_token = <aws_session_token>