Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

The awscli-login plugin allows retrieving temporary Amazon credentials by authenticating against a SAML Identity Provider (IdP). This application is supported under Linux, MacOS, and the Windows Subsystem for Linux. Currently, Windows PowerShell, Command Prompt, and Git Shell for Windows are not supported.

Installation

The simplest way to install the awscli-login plugin is to use pip:

$ pip install awscli-login

After awscli-login has been installed, run the following command to enable the plugin:

$ aws configure set plugins.login awscli_login

Getting Started

Before using awscli-login to retrieve temporary credentials, configure one or more profiles for use with the plugin. To configure this plugin, you must know the URL of the ECP Endpoint for your IdP. If you do not have this information, contact your IdP administrator.

Here is an example configuring the default profile for use with the University of Illinois at Urbana-Champaign’s IdP:

$ aws login configure
ECP Endpoint URL [None]: https://shibboleth.illinois.edu/idp/profile/SAML2/SOAP/ECP
Username [None]:
Enable Keyring [False]:
Duo Factor [None]:
Role ARN [None]:

To log in, type the following command:

$ aws login
Username [username]: netid
Password: ********
Factor: passcode
Code: 123456789

The username and password are the values needed to authenticate against the IdP configured for the selected profile. The factor is only required if your IdP requires Duo for authentication. If it does not, leave factor blank. If your IdP does require Duo then Factor may be one of auto, push, passcode, sms, or phone. If factor is left blank, auto is the default. The code is a Duo code useful for use with a YubiKey, SMS codes, or other one-time codes.

If you have access to more than one role, you will be prompted to choose one. For example:

$ aws login
Username [username]: netid
Password: ********
Factor:
Please choose the role you would like to assume:
    Account: 978517677611
        [ 0 ]: Admin
    Account: 520135271718
        [ 1 ]: ReadOnlyUser
        [ 2 ]: S3Admin
Selection: 2

To switch roles, first log out, then log in again selecting a different role. Note that if you log in to the same IdP using the same username, you will not be prompted for your password or Duo factor until the IdP session expires:

$ aws logout
$ aws login
Username [netid]:
Please choose the role you would like to assume:
    Account: 520135271718
        [ 0 ]: TestUser
        [ 1 ]: IAMUser
Selection: 0

If you want to show an account alias in the list of roles, you can generate one with:

$ aws login account_names --save

This will write a file to ~/.aws-login/accounts.ini that you can edit as needed. If you rerun the command it will add any accounts that do not exist, but will not change existing entries.

If you want to display the account alias on your shell prompt it is stored in ~/.aws-login/identity.txt and updated as you log in / out. You can use that file with a bash function like this:

aws_prompt_info() {
    local IDENTITY_FILE=~/.aws-login/identity.txt
    local PROF=""

    if [[ -f "$IDENTITY_FILE" ]] then

        PROF=$( cat "$IDENTITY_FILE" 2>/dev/null)
        [[ -n "$PROF" ]] && echo "[$PROF]"
    fi
}

Advanced Example

It is possible to be logged in to more than one role at the same time using multiple profiles. For example, consider the following configuration involving two profiles – one called prod, and the other test:

$ aws --profile prod login configure
ECP Endpoint URL [None]: https://shibboleth.illinois.edu/idp/profile/SAML2/SOAP/ECP
Username [None]: netid
Enable Keyring [False]: True
Duo Factor [None]: auto
Role ARN [None]: arn:aws:iam::999999999999:role/Admin

$ aws --profile test login configure
ECP Endpoint URL [None]: https://shibboleth.illinois.edu/idp/profile/SAML2/SOAP/ECP
Username [None]: netid
Enable Keyring [False]: True
Duo Factor [None]: passcode
Role ARN [None]: arn:aws:iam::111111111111:role/Admin

This example involves several advanced features. First, we are setting the username, factor, and role. This means we will not be prompted for this information when logging in to these two profiles. In addition, we are using a keyring. On the first login using one of the profiles, the user will be prompted for his password. On subsequent logins the user will not be prompted for his password because it has been stored in a secure keyring.

For example, when we initially log in to prod:

$ export AWS_PROFILE=test
$ aws login
Password: ********
Code: 123456789

We are only prompted for the password and code. We’re prompted for the password because this is the initial login, and the code because this profile is configured for use with a passcode device such as a YubiKey. We are now no longer prompted when we log in to test:

$ aws --profile prod login

Even if the IdP session has expired in this case, we will not be prompted for a password because it is stored in the keyring. The user will receive either a phone call or a push to the default Duo device.

Known Issues

Unable to authenticate after changing password

After the user changes his IdP password, subsequent logins fail. To remedy the situation, change the data stored in the keyring as follows:

$ keyring set awscli_login username@hostname_of_your_IdP

You may be prompted for your user login password by your operating system, depending on how your key store is configured.

Windows issues

Windows PowerShell, Command Prompt, and Git Shell for Windows are not currently supported because of problems with auto-renewal of AWS credentials, and other known issues.

Metadata

Release files for co-awscli-login 0.1.0a8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for co-awscli-login 0.1.0a8
File Size Uploaded
co-awscli-login-0.1.0a8.tar.gz 33.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for co-awscli-login 0.1.0a8
File Interpreter ABI Platform
co_awscli_login-0.1.0a8-py3-none-any.whl Python 3 none any Details

Total release size: 73.2 kB

Release files / co-awscli-login-0.1.0a8.tar.gz

Download URL co-awscli-login-0.1.0a8.tar.gz
Size 33.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f68ea9cedc86cf901cf10a54c9ce48a34030fef3e56ec64566c6e6cb519c0d1f
BLAKE2b-256 checksum
How to use checksums
dd99e967cf1ab2773b51226cbd3217883f9a2be6ceeca2a8fc8cdb95880691e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

Release files / co_awscli_login-0.1.0a8-py3-none-any.whl

Download URL co_awscli_login-0.1.0a8-py3-none-any.whl
Size 40.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
622b188e99e951ea2fef5d66ccf4e23b866bb8f37b2332d299c2a4cdd2416d0d
BLAKE2b-256 checksum
How to use checksums
7b79c0f5fc98125ae504b5b67e66b5c465638e66fef8b9f05a21459cd2711524
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page