{"id":22148690,"url":"https://github.com/kaicoh/awscli-mfa","last_synced_at":"2026-04-13T18:03:23.291Z","repository":{"id":65820515,"uuid":"594637611","full_name":"kaicoh/awscli-mfa","owner":"kaicoh","description":"Tool for AWS MFA(Multi Factor Authentication)","archived":false,"fork":false,"pushed_at":"2023-10-13T12:18:04.000Z","size":289,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-24T15:19:39.178Z","etag":null,"topics":["aws","awscli","mfa"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kaicoh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-29T06:47:15.000Z","updated_at":"2023-02-12T12:48:29.000Z","dependencies_parsed_at":"2024-12-01T23:40:33.608Z","dependency_job_id":null,"html_url":"https://github.com/kaicoh/awscli-mfa","commit_stats":{"total_commits":69,"total_committers":2,"mean_commits":34.5,"dds":0.01449275362318836,"last_synced_commit":"a1e04175cf9a7ef7093c08d737c4b9527680f31b"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaicoh%2Fawscli-mfa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaicoh%2Fawscli-mfa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaicoh%2Fawscli-mfa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaicoh%2Fawscli-mfa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaicoh","download_url":"https://codeload.github.com/kaicoh/awscli-mfa/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245274728,"owners_count":20588838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","awscli","mfa"],"created_at":"2024-12-01T23:29:09.399Z","updated_at":"2026-04-13T18:03:18.258Z","avatar_url":"https://github.com/kaicoh.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# awscli-mfa\n\n[![Version](https://img.shields.io/crates/v/awsmfa)](https://crates.io/crates/awsmfa)\n[![License](https://img.shields.io/crates/l/awsmfa)](LICENSE)\n[![Build](https://img.shields.io/github/actions/workflow/status/kaicoh/awscli-mfa/build.yml)](https://github.com/kaicoh/awscli-mfa/actions/workflows/build.yml)\n\nThe automation tool for Multi-Factor Authentication (MFA) process to use awscli. It generates one time password, gets session token of AWS STS and updates both AWS Credentials(`~/.aws/credentials`) and Config(`~/.aws/config`) files automatically and you can run any aws cli commands without [complecated process](https://aws.amazon.com/premiumsupport/knowledge-center/authenticate-mfa-cli/).\n\n## Installation\n\nYou can install **awsmfa** via `cargo install` command.\n\n```\n$ cargo install awsmfa\n```\n\nOr download the binary file from the [release page](https://github.com/kaicoh/awscli-mfa/releases).\n\n## Usage\n\n### 1. Configure config files\n\nFirst, make sure that the `mfa_serial` for the profile you want to use is defined in AWS Config(`~/.aws/config`). For more details about AWS Config and `mfa_serial`, see [the official document](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html).\n\n```\n[default]\nregion=us-east-1\noutput=json\nmfa_serial=arn:aws:iam::123456789012:mfa/kaicoh\n...\n\n[profile alpha]\nregion=ap-northeast-1\noutput=json\nmfa_serial=arn:aws:iam::999999999999:mfa/alpha\n...\n```\n\nThen, create `awsmfa.yml` in `~/.aws` directory and set secret key for each MFA device.\n\n```\nsecrets:\n  - profile: default\n    value: ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ01\n  - profile: alpha\n    value: ZYXWVUTSRQPONMLKJIHGFECDBA9876543210ZYXWVUTSRQPONMLKJIHGFECDBA98\n```\n\nYou can get the secret key for each MFA device during the registration process for that in AWS Consol. If you want some MFA codes in that process, run [otp subcommand](#otp).\n\n![How to get secret](https://github.com/kaicoh/awscli-mfa/raw/images/assets/How_to_get_secret.png)\n\n### 2. Run the command\n\n```\n$ awsmfa --profile alpha --duration 43200\nNew credentials is available as profile \"alpha-mfa\".\nIt is valid until 2023-01-31 09:00:00.\n```\n\nThis command generates one time password, gets session token of AWS STS and updates both AWS Credentials(`~/.aws/credentials`) and Config(`~/.aws/config`) files internally. After that, the new credentials and configurations are saved as `[profile]-mfa`.\n\n**~/.aws/credentials**\n\n```\n$ cat ~/.aws/credentials\n...\n\n[alpha-mfa] \u003c= The command creates this.\naws_access_key_id=ZZZZZZZZZZZZZZZZZZZZ\naws_secret_access_key=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\naws_session_token=aaaaaaaaa.....\n```\n\n**~/.aws/config**\n\n```\n$ cat ~/.aws/config\n...\n\n[profile alpha-mfa] \u003c= The command creates this.\nregion=ap-northeast-1\noutput=json\n```\n\n#### Options\n\n| name | short | requried | type | description |\n| :---: | :---: | :---: | :---: | :--- |\n| profile | p | no | string | The profile name to execute aws-sts `get-session-token` action. When not provided the `default` is used. |\n| duration | d | no | number | The duration seconds the generated credentials persists. |\n\n### 3. Run any aws cli commands with profile option\n\n```\n$ aws s3 ls --profile alpha-mfa\n...\n```\n\n## Subcommands\n\nThis binary has some subcommands to configure or operate MFA related processes.\n\n### otp\n\nOnce you [configure](#1-configure-config-files), you can generate MFA code(= one time password) from this command.\n\n```\n$ awsmfa otp --profile alpha --clip\n123456\n```\n\n#### Options\n\n| name | short | requried | type | description |\n| :---: | :---: | :---: | :---: | :--- |\n| profile | p | no | string | The profile name in the config file. When not provided the `default` is used. |\n| clip | c | no | bool | Whether copying the generated MFA code to the clipboad or not. |\n\n---\n\n### ls\n\nShow the current configuration from the `~/.aws/awsmfa.yml`.\n\n```\n$ awsmfa ls\n[profile default]\nsecret\t: ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ01\n\n[profile alpha]\nsecret\t: ZYXWVUTSRQPONMLKJIHGFECDBA9876543210ZYXWVUTSRQPONMLKJIHGFECDBA98\n```\n\n---\n\n### set\n\nSet the MFA device to the `~/.aws/awsmfa.yml`.\n\n```\n$ awsmfa set \\\n\u003e --profile beta \\\n\u003e --secret 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQR\nSave the secret key for profile \"beta\" successfully.\n\n$ awsmfa ls\n[profile default]\nsecret\t: ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ01\n\n[profile alpha]\nsecret\t: ZYXWVUTSRQPONMLKJIHGFECDBA9876543210ZYXWVUTSRQPONMLKJIHGFECDBA98\n\n[profile beta]\nsecret\t: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQR\n```\n\n#### Options\n\n| name | short | requried | type | description |\n| :---: | :---: | :---: | :---: | :--- |\n| profile | p | yes | string | The profile name in the config file. |\n| secret | s | yes | string | The secret key for the MFA device. |\n\n---\n\n### rm\n\nRemove the MFA device from the `~/.aws/awsmfa.yml`.\n\n```\n$ awsmfa rm --profile beta\nRemove the secret key for profile \"beta\" successfully.\n```\n\n#### Options\n\n| name | short | requried | type | description |\n| :---: | :---: | :---: | :---: | :--- |\n| profile | p | yes | string | The profile name in the config file. |\n\n## License\n\nThis software is released under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaicoh%2Fawscli-mfa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaicoh%2Fawscli-mfa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaicoh%2Fawscli-mfa/lists"}