All Projects → stefansundin → Aws Rotate Key

stefansundin / Aws Rotate Key

Licence: mit
Easily rotate your AWS access key. 🔑

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to Aws Rotate Key

Jql
A JSON Query Language CLI tool
Stars: ✭ 368 (+27.78%)
Mutual labels:  cli, tools
Micro Dev
The development environment for `micro`
Stars: ✭ 630 (+118.75%)
Mutual labels:  cli, tools
Protolock
Protocol Buffer companion tool. Track your .proto files and prevent changes to messages and services which impact API compatibility.
Stars: ✭ 394 (+36.81%)
Mutual labels:  cli, tools
Rawkit
🦊 Immediately Open Chrome DevTools when debugging Node.js apps
Stars: ✭ 306 (+6.25%)
Mutual labels:  cli, tools
Lumberjack
A terminal-ui log watcher written in Go using the Flux architecture
Stars: ✭ 31 (-89.24%)
Mutual labels:  cli, tools
Stup
Daily notes in the terminal 🐧
Stars: ✭ 340 (+18.06%)
Mutual labels:  cli, tools
Sherlock
🔎 Hunt down social media accounts by username across social networks
Stars: ✭ 28,569 (+9819.79%)
Mutual labels:  cli, tools
X Build
🖖 Customizable front-end engineering scaffolding tools
Stars: ✭ 436 (+51.39%)
Mutual labels:  cli, tools
Todo r
Find all your TODO notes with one command!
Stars: ✭ 28 (-90.28%)
Mutual labels:  cli, tools
Swiftinfo
📊 Extract and analyze the evolution of an iOS app's code.
Stars: ✭ 880 (+205.56%)
Mutual labels:  cli, tools
Gkill
Interactice process killer for Linux and macOS
Stars: ✭ 297 (+3.13%)
Mutual labels:  cli, tools
Teleconsole
Command line tool to share your UNIX terminal and forward local TCP ports to people you trust.
Stars: ✭ 2,750 (+854.86%)
Mutual labels:  cli, tools
Ghb0t
A GitHub Bot to automatically delete your fork's branches after a pull request has been merged.
Stars: ✭ 295 (+2.43%)
Mutual labels:  cli, tools
Hygen
The simple, fast, and scalable code generator that lives in your project.
Stars: ✭ 4,107 (+1326.04%)
Mutual labels:  cli, tools
Namecheck
Check your name idea availability with CLI
Stars: ✭ 19 (-93.4%)
Mutual labels:  cli, tools
Tooling
Advancing Node.js as a framework for writing great tools
Stars: ✭ 98 (-65.97%)
Mutual labels:  cli, tools
Supervizer
NodeJS Application Manager
Stars: ✭ 278 (-3.47%)
Mutual labels:  cli, tools
Dockrails
Simple CLI to Generate and Run a Rails environment with Docker (in Development) !
Stars: ✭ 282 (-2.08%)
Mutual labels:  cli
Vk
A console client for vk.com
Stars: ✭ 285 (-1.04%)
Mutual labels:  cli
Wallace Cli
Pretty CSS analytics on the CLI
Stars: ✭ 281 (-2.43%)
Mutual labels:  cli

aws-rotate-key

As a security best practice, AWS recommends that users periodically regenerate their API access keys. This tool simplifies the rotation of access keys defined in your credentials file.

When run, the program will list the current access keys associated with your IAM user, and print the steps it has to perform to rotate them. It will then wait for your confirmation before continuing.

Usage

$ aws-rotate-key --help
Usage of aws-rotate-key:
  -d	Delete old key without deactivation.
  -mfa
    	Use MFA.
  -profile string
    	The profile to use. (default "default")
  -version
    	Print version number
  -y	Automatic "yes" to prompts.

Example

$ aws-rotate-key --profile work
Using access key AKIAJMIGD6UPCXCFWVOA from profile "work".
Your user ARN is: arn:aws:iam::123456789012:user/your_username

You have 2 access keys associated with your user:
- AKIAI3KI7UC6BPI4O57A (Inactive, created 2018-11-22 21:47:46 +0000 UTC, last used 2018-11-30 20:35:41 +0000 UTC for service s3 in us-west-2)
- AKIAJMIGD6UPCXCFWVOA (Active, created 2018-11-30 21:55:57 +0000 UTC, last used 2018-12-20 12:14:10 +0000 UTC for service s3 in us-west-2)

You have two access keys, which is the max number of access keys.
Do you want to delete AKIAI3KI7UC6BPI4O57A and create a new key? [yN] y
Deleted access key AKIAI3KI7UC6BPI4O57A.
Created access key AKIAIX46CKYT7E5I3KVQ.
Wrote new key pair to /Users/your_username/.aws/credentials
Deactivated old access key AKIAJMIGD6UPCXCFWVOA.
Please make sure this key is not used elsewhere.
Please note that it may take a minute for your new access key to propagate in the AWS control plane.

Install

You can download binaries from the releases section.

You can use Homebrew to install on macOS:

brew install aws-rotate-key

Update November 2020: The program is now available in the official Homebrew repository. Earlier, this was facilitated with Homebrew taps. If you added any of the taps previously, you can remove them by running:

brew untap fullscreen/tap
brew untap stefansundin/tap

You can install using a PPA on Ubuntu Linux:

sudo add-apt-repository ppa:stefansundin/aws-rotate-key
sudo apt install aws-rotate-key

Setup

Make sure your users have permissions to update their own access keys. The following AWS documentation page explains the required permissions: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_delegate-permissions_examples.html#creds-policies-credentials.

The following IAM policy is enough for aws-rotate-key:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "iam:ListAccessKeys",
                "iam:GetAccessKeyLastUsed",
                "iam:DeleteAccessKey",
                "iam:CreateAccessKey",
                "iam:UpdateAccessKey"
            ],
            "Resource": [
                "arn:aws:iam::AWS_ACCOUNT_ID:user/${aws:username}"
            ]
        }
    ]
}

Replace AWS_ACCOUNT_ID with your AWS account id.

Require MFA

You can require MFA by adding a Condition clause. Please note that you have to use the -mfa option when running the program.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "iam:ListMFADevices"
            ],
            "Resource": [
                "arn:aws:iam::AWS_ACCOUNT_ID:user/${aws:username}"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "iam:ListAccessKeys",
                "iam:GetAccessKeyLastUsed",
                "iam:DeleteAccessKey",
                "iam:CreateAccessKey",
                "iam:UpdateAccessKey"
            ],
            "Resource": [
                "arn:aws:iam::AWS_ACCOUNT_ID:user/${aws:username}"
            ],
            "Condition": {
                "Bool": {
                    "aws:MultiFactorAuthPresent": true
                }
            }
        }
    ]
}

Note that this makes it harder to rotate access keys using aws-cli commands, as it only supports MFA when assuming roles. You will still be able to use the AWS management console.

Contribute

To download and hack on the source code, run:

git clone https://github.com/stefansundin/aws-rotate-key.git
cd aws-rotate-key
go build
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].