# AWS SSO login without a browser

How-to guides · Updated 16 November 2026

**Short answer:** On a machine with no browser, run aws sso login --use-device-code --no-browser. The CLI prints a verification URL and a code; open the URL on your laptop or phone, sign in, confirm the code, and the CLI on the headless machine receives its token. --no-browser on its own isn't enough with recent CLI versions, because the default login flow redirects back to a local address on the machine running the browser.

## The command

```
aws sso login --profile acme-dev --use-device-code --no-browser
```

Expected output is a line telling you to open a URL (on the identity provider's device page) and a code made of letters, such as `ABCD-EFGH`. Open the URL anywhere, check the code matches, sign in to your identity provider, and allow access. The waiting CLI then reports a successful login, and `aws sts get-caller-identity --profile acme-dev` works on that machine.

## Why --no-browser alone fails

Recent AWS CLI v2 versions default to the authorisation-code flow with PKCE. After you approve in the browser, the browser is redirected to a callback on `127.0.0.1`, meaning the computer the browser is running on. If that isn't the machine running the CLI (an SSH session, a dev container, a CI runner), the redirect lands nowhere and the CLI keeps waiting. The device-code flow has no redirect: the CLI polls the service until you confirm the code, so it works from any device.

| Where the CLI runs | Best option |
|---|---|
| Your laptop | Plain `aws sso login` |
| Remote host over SSH | `--use-device-code --no-browser` |
| Dev container / Codespace | `--use-device-code --no-browser`, or mount `~/.aws` from the host |
| CI pipeline, cron job | Don't use SSO at all: use an IAM role (OIDC federation for CI, instance or task role on AWS) |

## Alternative: export credentials from your laptop

```
# On the laptop (already logged in)
aws configure export-credentials --profile acme-dev --format env
# prints export AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... AWS_SESSION_TOKEN=... AWS_CREDENTIAL_EXPIRATION=...
```

Paste the output into the remote shell. These are temporary role credentials: they expire (the lifetime depends on the permission set), can't be refreshed on the remote side, and anyone who sees them can use them until then. Fine for a quick task; device-code login is better for a working session.

## Check before and after

- **CLI version:** `aws --version`. The `--use-device-code` option arrived in the same releases that made PKCE the default; older v2 releases already use device codes, so `--no-browser` alone works there.
- **Config:** the profile should reference an `sso_session`. Legacy profiles also work, but don't refresh tokens.
- **Network:** the headless machine must reach the Identity Center endpoints in your SSO Region over HTTPS. A TLS-inspecting proxy causes `CERTIFICATE_VERIFY_FAILED`; set `AWS_CA_BUNDLE`.
- **After:** the token is cached in `~/.aws/sso/cache` on that machine. Run `aws sso logout` when you're done on shared hosts.

## Common mistakes

- Copying `~/.aws/sso/cache` between machines. It may work briefly but is fragile and spreads tokens around.
- Approving a device code you didn't request. If a code appears that you didn't start, don't confirm it: device-code phishing relies on exactly that.
- Using personal SSO logins on shared servers that other people can sudo on.

## Questions

### How do I run aws sso login on a remote server?

Use aws sso login --use-device-code --no-browser on the server, then open the printed URL on your own device and confirm the code.

### Why does aws sso login hang after I approve in the browser?

With the default PKCE flow, the browser redirects to a local callback on the machine it runs on. If the CLI is on another machine, it never receives it. Use --use-device-code.

### Can I use AWS SSO in a CI pipeline?

Not sensibly, since it needs a person to approve. Use OIDC federation from the CI system to an IAM role instead.

## When this happens away from your desk

Approving a sign-in from your phone for a machine somewhere else is already routine. CloudConsole, a phone app for AWS, is built with the same idea of short-lived, clearly scoped access when you are away from a laptop.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Configuring IAM Identity Center authentication with the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html)
- [AWS CLI reference: sso login](https://docs.aws.amazon.com/cli/latest/reference/sso/login.html)

## Related

- [How to log in to AWS SSO from the CLI](https://cloudconsole.dev/how-to/aws-sso-login-cli)
- [aws sso login](https://cloudconsole.dev/cli/sso-login)
- [aws configure export-credentials](https://cloudconsole.dev/cli/configure-export-credentials)
- [Error when retrieving token from sso: Token has expired and refresh failed](https://cloudconsole.dev/errors/sso-token-expired-refresh-failed)
- [SSL validation failed for https://... certificate verify failed](https://cloudconsole.dev/errors/ssl-validation-failed)
- [How to add my IP to an AWS security group](https://cloudconsole.dev/how-to/add-my-ip-to-security-group)

---

Source: https://cloudconsole.dev/how-to/aws-sso-login-without-browser

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
