Sealing credentials with AWS Credential Daemon
Built-in support for AWS Credential Daemon in the AWS CLI is a developer preview under active development. Don't use it in production environments. For more information, see Preview scope and limitations.
AWS Credential Daemon (credsd) is a local service that stores, or seals, your AWS CLI version 2 credentials in a
protected local backend, instead of in plaintext config and
credentials files. The AWS CLI then requests short-lived credentials from the
daemon each time it runs a command. This feature is available in the AWS CLI version 2 only.
Using the daemon is opt-in for each profile. Installing the daemon never changes a profile, and the AWS CLI never moves a profile without asking.
The daemon records the process tree of each caller in its own local audit log. This log is best-effort local telemetry that can help you review which processes on your computer requested credentials.
This topic covers the credential sources that you set up through the AWS CLI. For the client
commands, other credential sources such as IAM Roles Anywhere and web identity, and conceptual
information, see Using
AWS Credential Daemon in the IAM User Guide and the AWS Credential Daemon documentation
Topics
Preview scope and limitations
Built-in support for AWS Credential Daemon in the AWS CLI is a developer preview. This section lists the commands that this release supports and the known limitations to plan for.
This release supports the following commands.
Command |
What it does |
|---|---|
|
Stores an AWS sign-in session in the daemon. |
|
Signs a stored session out of the daemon. |
|
Stores access keys for a new profile in the daemon. It doesn't move an existing profile's keys. |
|
Exports a daemon-backed profile's credentials for a tool that reads
|
|
Downloads and installs the daemon. |
|
Connects the AWS CLI to the daemon. |
|
Uninstalls the daemon. |
Known limitations
This release has the following known limitations.
-
Credentials in the daemon aren't in the credentials file. When
aws configurestores a new profile's access keys in the daemon, the AWS CLI doesn't write them to~/.aws/credentials. A tool that reads that file directly, instead of through the AWS CLI or a supported AWS SDK, can't find that profile's credentials. For more information, see Store access keys for a new profile. -
The AWS SDKs don't read the daemon's profile setting. During the Preview, the AWS SDKs have no native understanding of the
credential_daemonsetting. As a result, a tool built on an AWS SDK can't use a daemon-backed profile directly. As a workaround, add acredential_processline that gets credentials from the daemon through the AWS CLI. For more information, see Use daemon profiles with older SDKs and tools. -
Some features aren't supported yet. IAM Identity Center sign-in,
aws signup, and moving an existing profile's credentials into the daemon aren't supported yet. They're planned for future preview versions.
Prerequisites
-
Install the developer preview AWS CLI and AWS Credential Daemon. For steps, see Installing AWS Credential Daemon.
How the AWS CLI decides where to store credentials
The first time a command stores credentials for a profile, such as aws login
or interactive aws configure, the AWS CLI asks whether
to store them in the daemon. The AWS CLI saves your answer in the profile, so it asks once per
profile. The following settings control
where the AWS CLI stores credentials for a profile.
Setting |
Meaning |
|---|---|
|
Store this profile's credentials in the daemon. An
|
|
Keep this profile's credentials in |
|
The profile's credentials are in the daemon, under this name. The AWS CLI writes this setting. Don't edit it. |
To set the choice for every profile, for example on a fleet, set the
AWS_CREDENTIAL_STORAGE environment variable to daemon or
file. The AWS CLI then never asks.
The AWS CLI doesn't ask, and keeps using files, when it isn't running in a terminal (for example, in a script or a cron job), or when the daemon isn't running.
Store an AWS sign-in session
To store a browser-based AWS sign-in session in the daemon, use the following procedure.
-
Sign in.
$aws login --profile dev -
When the AWS CLI asks whether to store the session in the daemon, press Enter (yes is the default).
The credential daemon is installed on this machine. Store this profile's session there instead of in ~/.aws? Tools built on older AWS SDKs won't be able to use this profile (see docs for a workaround). [Y/n] -
Complete the sign-in in your browser. The AWS CLI confirms where the session is stored. If the profile already had a session file in
~/.aws/login/cache, the AWS CLI moves that session into the daemon and deletes the file.Signed in as arn:aws:sts::123456789012:assumed-role/Dev/alice Credentials are stored in the credential daemon.
Your commands don't change, and programs get the same short-lived credentials as before.
The profile now holds only the storage choice and the name of its credential in the daemon:
credential_storage = daemon and credential_daemon =
login.123456789012-role-Dev. The credential is named after the identity you signed in
as: login.<account>-role-<role> for a role,
login.<account>-user-<name> for an IAM user, or
login.<account>-root for the root user. Two profiles that sign in as the same
identity share one credential.
In a terminal, aws login asks for the profile's region, defaulting to the
account's home region, and saves it to the profile. When there's no terminal, the region is
left unset, so set region separately if the profile needs one. To store a profile
in the daemon without being asked, run aws configure set credential_storage daemon
--profile dev before you sign in.
If you sign in again as the same account and role, the AWS CLI refreshes the session without asking. If you sign in as a different account or role, the AWS CLI asks before it points the profile at the new identity.
To sign in on a computer without a browser, such as an Amazon EC2 instance that you reach through Session Manager, a capability of AWS Systems Manager, use the following procedure.
-
Run the sign-in command with the
--remoteoption, and answer the storage question.$aws login --profile dev --remote -
On another computer where you're signed in to the AWS Management Console, open the sign-in URL that the AWS CLI prints, and approve the request.
-
Copy the authorization code that the browser shows, and paste it at the prompt. Nothing listens on the computer that you're signing in from.
Store access keys for a new profile
Existing access keys in ~/.aws/credentials stay there. The AWS CLI
shows a reminder only when aws login or aws configure writes a
secret to a file, not when a command uses existing keys.
To store new access keys directly in the daemon, use the following procedure.
-
Run the
aws configurecommand, and enter the access key ID, secret access key, and Region. When the AWS CLI asks where to store the keys, entery. The AWS CLI doesn't write the keys to~/.aws/credentials, and the credential is namedkeys.<profile>.$aws configure --profile ciAWS Access Key ID [None]:AKIAIOSFODNN7EXAMPLEAWS Secret Access Key [None]:****Default region name [None]:us-east-1Default output format [None]:Store these keys in the credential daemon instead of ~/.aws/credentials? Programs will get temporary credentials, so some things stop working (IAM calls without MFA, long presigned URLs). Older AWS SDKs can't use this profile (see docs for a workaround). [Y/n]yStored in the credential daemon. -
Confirm that the keys are stored. The type is
credential-daemon.$aws configure list --profile ciNAME : VALUE : TYPE : LOCATION profile : ci : manual : --profile access_key : ****************RR6L : credential-daemon : secret_key : ****************lRqr : credential-daemon : region : us-east-1 : config-file : /home/alice/.aws/config
Scripted aws configure set and aws configure import --csv keep
writing to files.
Move a profile back to files
You can move an AWS sign-in profile from the daemon back to the local files. You can't move IAM access keys back.
-
Set the profile to use files.
$aws configure set credential_storage file --profile dev -
Sign in again. The session moves back to
~/.aws, and the daemon's copy is cleared.$aws login --profile dev
Use daemon profiles with older SDKs and tools
Tools built on older AWS SDKs, for example older versions of the AWS SDK for Python
(Boto3), Terraform built on an older AWS SDK for Go, and older IDE toolkits, can't read
credential_daemon. On your computer, they fail with "Unable to locate
credentials". On Amazon EC2, Amazon ECS, Amazon EKS, or AWS CodeBuild, many of them silently use the host's role
instead, which is a different identity.
To let older tools use an AWS sign-in or access key profile, add a
credential_process line that gets credentials from the daemon through the AWS CLI.
Use the full path to aws.
$aws configure set credential_process "$(which aws) configure export-credentials --profile dev --format process" --profile dev
Check your credentials and sign out
Use the following commands to check daemon-backed profiles and to sign out.
-
To see which credentials and settings the AWS CLI uses for a profile, run the
aws configure listcommand. The typecredential-daemonshows that the profile is backed by the daemon. The access key it shows is the temporary key the daemon issued, not your access key ID, which is how you can tell that the keys moved.$aws configure list --profile ci -
Run the
aws sts get-caller-identitycommand to confirm the identity. For moved access keys, the output still shows the IAM user, becauseGetSessionTokencredentials keep the user's ARN.$aws sts get-caller-identity -
Run the
creds listcommand to see what the daemon holds.$creds listkeys.ci session_credentials active -
Run the
aws logoutcommand to sign a session out of the daemon. The profile keepscredential_daemon, soaws login --profile devrestores it without asking.$aws logout --profile devSigned out of profile 'dev' in the credential daemon. Note, any local developer tools that have already loaded its credentials may continue to use them until they expire, in at most 15 minutes.
Signing out keeps the credential's entry and shows it as no session in
creds list. It doesn't revoke credentials the daemon has already issued: tools
that loaded them can keep using them until they expire, within 15 minutes.
Troubleshooting
The following table lists issues that can occur when you use AWS Credential Daemon with the AWS CLI, and how to resolve them.
Problem |
Cause |
Solution |
|---|---|---|
"The credential daemon isn't running: there's no socket at ~/.aws/credential-daemon.sock." |
The service stopped or was uninstalled. |
Run |
"Session for profile 'dev' has ended. Run |
The stored session expired or was signed out. |
Sign in again. |
An older tool reports "Unable to locate credentials" for a daemon profile. |
The tool's AWS SDK doesn't support the daemon. |
Add a |
A program on Amazon EC2, Amazon ECS, Amazon EKS, or AWS CodeBuild uses the host's role instead of your profile. |
The older AWS SDK skipped the profile and fell back to the host role. |
Add a |
|
The daemon can't decrypt a credential, for example after a storage backend change. |
Sign in again with |
After an upgrade, stored credentials show |
The new version keeps its key in a different slot and can't read credentials sealed under the old one. |
Run |
A change fails with |
The change replaces or removes a credential. |
Approve it with |
A write fails with |
The daemon can't verify its configuration files, for example after an upgrade or a manual edit. |
Run |
|
The service can't open the TPM yet. |
Press Ctrl+C, run |
"--redirect-port must be between 1024 and 65535 when the credential daemon signs you in." |
The daemon can't listen on ports below 1024. |
Choose a port from 1024 to 65535. |
Every |
The commands log at the |
Add |