ByteNess/aws-vault 是一个托管在 GitHub 上的开源项目,主要使用 Go 编写,采用 MIT License 许可证,目前获得 505 个 Star、37 次 Fork。
仓库全名
ByteNess/aws-vault
README 摘要
[!NOTE] This is a maintained fork of which is an abandoned project. Contributions are welcome and preferably please open an issue first. AWS Vault is a tool to securely store and access AWS credentials in a development environment. AWS Vault stores IAM credentials in your operating system's secure keystore and then generates temporary credentials from those to expose to your shell and applications. It's designed to…
[!NOTE]
This is a maintained fork of https://github.com/99designs/aws-vault which is an abandoned project.
Contributions are welcome and preferably please open an issue first.
AWS Vault is a tool to securely store and access AWS credentials in a development environment.
AWS Vault stores IAM credentials in your operating system’s secure keystore and then generates temporary credentials from those to expose to your shell and applications. It’s designed to be complementary to the AWS CLI tools, and is aware of your profiles and configuration in ~/.aws/config.
The supported vaulting backends can be found in the respective documentation section.
Use the --backend flag or AWS_VAULT_BACKEND environment variable to specify a backend.
Run aws-vault --help to see the backends available in your build and environment.
By default, aws-vault selects the first available backend for the platform:
wincred on Windows, keychain on macOS, and secret-service on Linux when Secret Service is available.
On Linux, automatic selection then falls back through kwallet, keyctl, pass, passage, and file.
The 1Password, Proton Pass and oo7 backends are opt-in and are listed after file, so choose them explicitly with --backend or AWS_VAULT_BACKEND.
Over SSH or in headless sessions, where Secret Service cannot prompt to unlock a collection, oo7 stores credentials in an oo7 keyring file with no daemon or prompt involved.
Quick start
# Store AWS credentials for the "jonsmith" profile
$ aws-vault add jonsmith
Enter Access Key Id: ABDCDEFDASDASF
Enter Secret Key: ****************************************
Enter MFA Device ARN (If MFA is not enabled, leave this blank): arn:aws:iam::123456789012:mfa/jonsmith
Added credentials to profile "jonsmith" in vault
# Execute a command (using temporary credentials)
$ aws-vault exec jonsmith -- aws s3 ls
bucket_1
bucket_2
# open a browser window and login to the AWS Console
$ aws-vault login jonsmith
# List credentials
$ aws-vault list
Profile Credentials Sessions
======= =========== ========
jonsmith jonsmith -
# Start a subshell with temporary credentials
$ aws-vault exec jonsmith
Starting subshell /bin/zsh, use `exit` to exit the subshell
$ aws s3 ls
bucket_1
bucket_2
How it works
aws-vault uses Amazon’s STS service to generate temporary credentials via the GetSessionToken or AssumeRole API calls. These expire in a short period of time, so the risk of leaking credentials is reduced.
AWS Vault then exposes the temporary credentials to the sub-process in one of two ways
Environment variables are written to the sub-process. Notice in the below example how the AWS credentials get written out
When the account the credentials belong to is known from the profile config (role_arn, sso_account_id or aws_account_id), AWS_ACCOUNT_ID is exposed too.
Local metadata server is started. This approach has the advantage that anything that uses Amazon’s SDKs will automatically refresh credentials as needed, so session times can be as short as possible.
Since v7.3+ aws-vault introduced option to automatically try and do a logout first, before login when executing aws-vault login <profile>.
This behavour can be achieved by using --auto-logout or -a flag! Read more in the Managing Sessions docs.
Development
The macOS release builds are code-signed to avoid extra prompts in Keychain. You can verify this with:
codesign --verify --verbose $(which aws-vault)
If you are developing or compiling the aws-vault binary yourself, you can generate a self-signed certificate by accessing Keychain Access > Certificate Assistant > Create Certificate -> Certificate Type: Code Signing. You can then sign your binary with:
go build .
codesign --sign <Name of certificate created above> ./aws-vault
🧰 Contributing
Report issues/questions/feature requests on in the issues section.
评论