CloudConsole

aws sso login

Updated 16 November 2026 · How we write and check guides

Short answer

aws sso login --profile my-profile signs you in to IAM Identity Center through your browser and caches a token that the CLI uses to get short-lived credentials for every profile sharing that SSO session. On a machine without a browser, add --no-browser or --use-device-code and complete the sign-in on another device.

Terminal running aws sso login --profile prod-readonly --use-device-code with its example output
A worked example from this page with its output. Copy commands from the text below, not from the image.

What the command does

It starts an OAuth flow against Identity Center, stores the resulting access token under ~/.aws/sso/cache/, and returns. Later commands use that token to fetch temporary role credentials for the account and role in your profile. The token lasts as long as the Identity Center session duration set by your administrator (commonly 8 hours), after which you log in again.

The profile must already exist; create it with aws configure sso.

Syntax

aws sso login [--profile <profile> | --sso-session <session>] \
  [--no-browser] [--use-device-code]

Worked examples

Normal login:

aws sso login --profile prod-readonly
aws sts get-caller-identity --profile prod-readonly

Log in once for all profiles in a session:

aws sso login --sso-session acme

On a remote server over SSH, with no browser. The CLI prints a URL (and, with device code, a short code) to open on your laptop or phone:

aws sso login --profile prod-readonly --use-device-code
Browser will not be automatically opened.
Please visit the following URL:

https://device.sso.eu-west-2.amazonaws.com/

Then enter the code:

ABCD-EFGH

Without opening a browser on this machine but keeping the default flow:

aws sso login --profile prod-readonly --no-browser

Recent CLI versions use an authorisation-code flow that redirects back to a local port on the machine running the CLI. That works when the browser is on the same machine; over SSH, the device code flow is the reliable choice.

Checking you are signed in

Before debugging a permissions problem, confirm which identity the CLI is actually using. The ARN shows the account and the permission set's role:

aws sts get-caller-identity --profile prod-readonly --query Arn --output text
arn:aws:sts::123456789012:assumed-role/AWSReservedSSO_ReadOnly_0123456789abcdef/[email protected]

If this fails with a token error, log in again; if it shows a different account or role than you expected, you are using the wrong profile. See checking who is logged in.

Errors

MessageFix
The SSO session associated with this profile has expired or is otherwise invalidRun aws sso login again; see token expired.
Error loading SSO TokenThe cache is missing or corrupt, or the profile points to a session you never logged in to; see this error.
The config profile (x) could not be foundProfile name typo; list them with list-profiles.
Browser shows an error after sign-inWrong start URL or SSO Region in the sso-session section.

Gotchas

  • One login per session, not per profile. Profiles that share an sso_session are all covered; profiles with different sessions need separate logins.
  • The login URL is your start URL. "What is my SSO login URL?" is answered by sso_start_url in the [sso-session] block of ~/.aws/config.
  • Scripts cannot do this unattended. A human has to approve each login. For automation, use roles, not SSO.
  • Other tools such as Terraform or Docker credential helpers use the same cache if their SDK supports SSO; otherwise bridge with export-credentials.

Questions

How do I use aws sso login without a browser?

Run aws sso login --use-device-code (or --no-browser). Open the printed URL on any device, sign in, and enter the code if asked; the CLI finishes once you approve.

How long does an aws sso login session last?

As long as the session duration configured in IAM Identity Center, often 8 hours by default and adjustable by administrators. Role credentials fetched with it are shorter-lived and refreshed automatically.

Do I need to log in for every profile?

No. Log in once per sso-session; every profile that references it shares the token.

When this happens away from your desk

Re-authenticating before you can even look at a problem costs minutes during an incident. CloudConsole is built to show alarms, logs and resources on a phone, so the first look is quicker.

About the app → · Download on the App Store

Sources