Giter Site home page Giter Site logo

aws-auth-script's Introduction

aws-auth-script

Description

This script allows to get new auth keys from AWS for 9-hour access.

It's is supposed, that you can do all the stuff via aws-iam-authenticator and aws cli, which is boring, the script helps avoid that routine.

The script assumes, that your user is created in IAM and has enabled MFA.

Preparations

  1. Install aws cli.

  2. Install aws-iam-authenticator tool.

  3. It is assumed, that you already have <homefolder>/.aws/credentials file with default profile.

    The default profile must contain your Access and Secret keys, generated with AWS Console web app.

    [default]
    aws_access_key_id = AKAS12313123asd
    aws_secret_access_key = asdfsar123123ASD131zxsas1123szfdasddsf32
  4. Scripts requires jq tool to be isntalled.

    Download binary file and place it into any PATH folder.

    Or use any package manager you want (apt, snap, chocolatey, etc.).

Installation

  1. Copy script file to any Path folder

  2. Define AWS_MFA_SERIAL_NUMBER environment variable with value like arn:aws:iam::1234567890123:mfa/kuser.

    You can get this value from you user edit page in IAM.

Usage

  1. Open terminal/console and run the script.

    NOTE: The script must be run with administrator rights.

  2. Provide MFA Identifier, if you did not define AWS_MFA_SERIAL_NUMBER environment variable.

  3. Provide MFA Verification code from your MFA device.

The script creates mfa profile in your <homefolder>/.aws/credentials file.

[mfa]
aws_access_key_id = AS123AVCSDF23ASDF
aws_secret_access_key = 312SDFASD2134ZDFASDf4345SADFASDF23423AS
aws_session_token = <long-long-very-long-string-here>

Use that profile to access to Amazon Console.

You can specify it in commands:

aws s3 ls --profile mfa

Or you can set default profile in environment variable:

  • bash:

    echo "\nexport AWS_PROFILE=mfa\n" >> ~/.bashrc
  • pwsh

    [System.Environment]::SetEnvironmentVariable("AWS_PROFILE", "mfa", "User")

aws-auth-script's People

Contributors

kirill-d-lappo avatar

Watchers

 avatar  avatar  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.