Code Monkey home page Code Monkey logo

aws-vault's Introduction

AWS Vault

Downloads Go Report Card

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 backends are:

Check out the announcement blog post for more details.

Installing

You can install aws-vault:

  • by downloading the latest release
  • on macOS via Homebrew Cask with brew cask install aws-vault
  • on Linux via Homebrew on Linux with brew install aws-vault
  • on Windows via choco with choco install aws-vault
  • on Archlinux via the AUR
  • by compiling with go get github.com/99designs/aws-vault

Basic Usage

# Store AWS credentials for the "jonsmith" profile
$ aws-vault add jonsmith
Enter Access Key Id: ABDCDEFDASDASF
Enter Secret Key: %%%

# 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                 -

See the USAGE document for more help and tips.

Security

$ aws-vault exec jonsmith -- env | grep AWS
AWS_VAULT=jonsmith
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=%%%
AWS_SECRET_ACCESS_KEY=%%%
AWS_SESSION_TOKEN=%%%
AWS_SECURITY_TOKEN=%%%

Notice in the above environment how a session token gets written out. This is because 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.

The credentials are exposed to the subprocess in one of two ways:

  • Environment variables are written to the sub-process.

  • Local EC2 Instance 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. The downside is that only one can run per host and because it binds to 169.254.169.254:80, your sudo password is required.

The default is to use environment variables, but you can opt-in to the local instance metadata server with the --server flag on the exec command.

Roles and MFA

Best-practice is to create Roles to delegate permissions. For security, you should also require that users provide a one-time key generated from a multi-factor authentication (MFA) device.

First you'll need to create the users and roles in IAM, as well as setup an MFA device. You can then set up IAM roles to enforce MFA.

Here's an example configuration using roles and MFA:

[default]
region = us-east-1

[profile jonsmith]
mfa_serial = arn:aws:iam::111111111111:mfa/jonsmith

[profile readonly]
role_arn = arn:aws:iam::22222222222:role/ReadOnly
source_profile = jonsmith

[profile admin]
role_arn = arn:aws:iam::22222222222:role/Administrator
source_profile = jonsmith
mfa_serial = arn:aws:iam::111111111111:mfa/jonsmith

[profile otheraccount]
role_arn = arn:aws:iam::333333333333:role/Administrator
source_profile = jonsmith
mfa_serial = arn:aws:iam::111111111111:mfa/jonsmith

When you use the readonly profile, aws-vault will use the credentials found in the source_profile jonsmith, and generate temporary credentials for the ReadOnly role using STS AssumeRole. When you use the prod-admin profile, aws-vault will first use GetSessionToken to establish an MFA session before an AssumeRole for Administrator. This MFA session is stored in your keychain so you only have to enter your MFA once, and using otheraccount will not cause another MFA prompt.

macOS Code Signing

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 > Code Signing Certificate. You can then sign your binary with:

$ go build .
$ codesign --sign "Name of my certificate" ./aws-vault

References and Inspiration

aws-vault's People

Contributors

adrienkohlbecker avatar alexisde avatar alexrudd avatar amitsaha avatar avinson avatar crashgoboom avatar dgoodlad avatar e1ven avatar frezbo avatar gatsbys avatar gbataille avatar gregwebs avatar gsterjov avatar issyl0 avatar joho avatar jolexa avatar jonhadfield avatar jstewmon avatar kevinburke avatar kevinburkeomg avatar lox avatar mtibben avatar pda avatar porty avatar reegnz avatar rekahsoft avatar scottrigby avatar simpson-ross avatar xocasdashdash avatar zoidbb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.