项目作者: future-architect

项目描述 :
replaces the credentials for MFA in AWS
高级语言: Go
项目地址: git://github.com/future-architect/awsmfa.git
创建时间: 2020-10-22T22:51:34Z
项目社区:https://github.com/future-architect/awsmfa

开源协议:Apache License 2.0

下载


awsmfa (AWS MFA Refresher)

Test Status
Apache-2.0 license

awsmfa replaces the config and credentials for MFA in AWS.

Usage

  1. $ awsmfa [options] [token-code]
  • The config file uses ~/.aws/config by default. You can override it with the environment variable AWS_CONFIG_FILE.
  • The credentials file uses ~/.aws/credentials by default. You can override it with the environment variable AWS_SHARED_CREDENTIALS_FILE.

Options

  1. --profile string
  2. The name of the profile from which the session can be obtained (default `default`)
  3. --mfa-profile-name string
  4. MFA profile name (default `mfa`)
  5. --duration-seconds int64
  6. Session expiration duration secounds (default `43200`)
  7. --serial-number string
  8. AWS serial number. `--serial-number` is required
  9. --quiet bool
  10. if enabled, log is not printed in the console. (default `false`)

Example

  1. $ awsmfa --serial-number arn:aws:iam::123456789012:mfa/future-architect --profile my-profile 123456
  2. 2021/02/28 11:01:49 Wrote session token for profile mfa, expiration: 2021-02-28 14:01:49.689 +0000 UTC

initial

  • .aws/config




BeforeAfter


ini [default] region = us-east-1 output = json



ini [default] region = us-east-1 output = json [profile mfa]
  • .aws/credentials




BeforeAfter


ini [default] aws_access_key_id = ABCDEFGHIJKLMNOPQRST aws_secret_access_key = ChcdJbC9kraRNW5iy8XgDyR4QNRT44kKRPmKEGQT



ini [default] aws_access_key_id = ABCDEFGHIJKLMNOPQRST aws_secret_access_key = ChcdJbC9kraRNW5iy8XgDyR4QNRT44kKRPmKEGQT [mfa] aws_access_key_id = AKIAIOSFODNN7EXAMPLE aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY aws_session_token = AQoEXAMPLEH4aoA....

next time

Update aws_access_key_id, aws_secret_access_key and aws_session_token in the target section (default is mfa) of .aws/credentials.

Installation

  • From binary
  1. # Install the latest version. (Install it into ./bin/ by default).
  2. $ curl -sfL https://raw.githubusercontent.com/future-architect/awsmfa/master/install.sh | sh -s
  3. # Specify installation directory ($(go env GOPATH)/bin/) and version.
  4. $ curl -sfL https://raw.githubusercontent.com/future-architect/awsmfa/master/install.sh | sh -s -- -b $(go env GOPATH)/bin [vX.Y.Z]

On Windows, you can run the above commands with Git Bash, which comes with Git for Windows.

  • From source code
  1. $ go install github.com/future-architect/awsmfa/cmd/awsmfa@latest