Skip to main content

A Python script and library for managing MFA token and AWS Session tokens.

Project description

Auto AWS MFA

Auto AWS MFA (autoawsmfa) is a script for managing AWS Session tokens enabled with MFA, this can also be used to generate MFA tokens for other applications that provides secret key while configuring MFA.

Installation

Requirements

autoawsmfa is built using the botocore & boto3 library and Python 3.5+. Python 2 is not supported. autoawsmfa also requires keyring, pyotp and pyperclip (available on pip).

Installation from Pip

pip install AutoAWSMFA

Installation From Source Code

Clone the repository:

git clone git@github.com:pmadhyasta/autoawsmfa.git

Then install with Pip:

cd autoawsmfa
pip install .

Usage

usage: autoawsmfa [-h] [-v] [-p PROFILE] [--credential-path CREDENTIAL_PATH] [--arn ARN] {mfa,session} ...

Auto update your AWS CLI MFA session token

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show the version number and exit
  -p PROFILE, --profile PROFILE
                        AWS profile to store the session token. Default looks for "AWS_PROFILE"
  --credential-path CREDENTIAL_PATH
                        path to the aws credentials file
  --arn ARN             AWS ARN from the IAM console (Security credentials -> Assigned MFA device). This is saved to your .aws/credentials file

subcommand:
  The subcommand to use among this suite of tools

  {mfa,session}         Select a subcommand to execute
    mfa                 Add MFA secret configuration key or get a token for registered MFA secret
    session             Start AWS CLI MFA session, use stored token or provide custom token "--custom-token"

Manage MFA

Add Secret

Add a new MFA secret to a specific AWS Profile

autoawsmfa --profile <profile name> mfa --add-secrete

Profile name should exist in '~/.aws/credentials' for posix or in '%UserProfile%.aws\credentials' fot NT/windows

Get Secret

Get MFA token from earlier added secret, token copied to clipboard to be used to login to AWS Console

autoawsmfa --profile <profile name> mfa --get-token

If the secret is not added earlier for the specified profile, it will prompt to add secret

Delete Secret

Delete secret from keyring

autoawsmfa --profile <profile name> mfa --del-secret

Optional arguments that can be used

usage: autoawsmfa mfa [-h] (--add-secret | --get-token | --del-secret) [--non-aws]

Manage MFA

optional arguments:
  -h, --help    show this help message and exit
  --add-secret  Add MFA secret configuration key and genereate session tokens
  --get-token   Display token, valid for 30 sec. Token added to clipboard to be used for GUI console login
  --del-secret  Delete stored secret
  --non-aws     Store non aws secret and generate MFA token

Non AWS MFA

This can be used to register the non AWS secrets such as OKTA or any thirdparty MFA enabled application. This option prompts for application name and user name to register and retrieve token. You shoud make a note of application name and user name while registring as currently there is no option to list view the secrets stored.

autoawsmfa mfa --non-aws --get-token

Manage AWS Session

Start session

Start the session for MFA secret registered profile

autoawsmfa --profile <profile name> session --start

Optional arguments can be given for duration and if a third party MFA device token should be used

usage: autoawsmfa session [-h] --start [--duration DURATION] [--custom-token CUSTOM_TOKEN]

Manage AMS CLI MFA session

optional arguments:
  -h, --help            show this help message and exit
  --start               Start AWS MFA session for the selected profile
  --duration DURATION   Specify session token duration in minutes before it expires. Duration limitation as per AWS is
                        minimum 15 and maximum 720 minutes, default is 720 minutes/12 Hrs
  --custom-token CUSTOM_TOKEN
                        Provide 6 digit token from your MFA devices

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

AutoAWSMFA-0.0.4.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

AutoAWSMFA-0.0.4-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file AutoAWSMFA-0.0.4.tar.gz.

File metadata

  • Download URL: AutoAWSMFA-0.0.4.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for AutoAWSMFA-0.0.4.tar.gz
Algorithm Hash digest
SHA256 5b7ae1fb2e2f86bdb4b387118cafe676544552272f1cdfd083449840f58e3f02
MD5 50d3ab2945d893be7a457487ce02830e
BLAKE2b-256 c7b451b4fa3b55fbd08242867d3d52098ec72527df43dbfa9b088eadd0b057b3

See more details on using hashes here.

File details

Details for the file AutoAWSMFA-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: AutoAWSMFA-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for AutoAWSMFA-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 613c0fdabf43c0f3cde658c09f0aeff09595d855c1e4116923fc8ab269ca1fdb
MD5 5921e8871cf6a631736bfe6c9e74ffb8
BLAKE2b-256 ed7e75f589e2845f77b861d8b18fe4ffd99c50a00dfb5c65ec230944ebbbe6a5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page