Install AWS CLI version 2 and configure credentials
At the end you will have the aws command installed, a working profile signed in through IAM Identity Center (or access keys), and proof of which account and role you are using. If you cannot install software, use AWS CloudShell.
What you need before step 1
Applies to: AWS CLI version 2 on 64-bit Windows, macOS 11 or later, and Linux x86_64 or ARM (aarch64), as documented by AWS
Admin roles you need
- Local administrator on Windows for the all-users MSI (AWSCLIV2.msi). The current-user MSI (AWSCLIV2-User.msi) does not need admin rights
- sudo on macOS or Linux for an all-users install
- For aws configure sso: access to an IAM Identity Center permission set in the target account. AWS suggests the predefined PowerUserAccess permission set unless your organisation has created its own
- For aws configure: an IAM user access key (AWS marks long-term credentials as not recommended)
Licences
None needed.
Download
https://awscli.amazonaws.com/AWSCLIV2.msiDownloadhttps://awscli.amazonaws.com/AWSCLIV2.pkgDownloadhttps://awscli.amazonaws.com/awscli-exe-linux-x86_64.zipDownloadInstall instructions
https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.htmlInstall stepsAlso have ready
- For SSO: your AWS access portal start URL (for example https://my-sso-portal.awsapps.com/start) and the Region where IAM Identity Center runs
- Linux: glibc, groff, less and unzip installed
9 steps
- 1
Install on Windows
Where: Windows PC: right-click Start and select Terminal (Admin), or run Command Prompt as administratorRun the MSI straight from the AWS URL. Follow the installer prompts. If you do not have admin rights, use the current-user MSI instead (second line).
msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2-User.msiYou should see: The AWS Command Line Interface v2 setup wizard opens and completes. - 2
Or install on macOS
Where: Mac: Finder > Applications > Utilities > TerminalEither download
https://awscli.amazonaws.com/AWSCLIV2.pkg, open it and follow the on-screen instructions, or run the two commands below to install for all users.curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg" sudo installer -pkg AWSCLIV2.pkg -target /You should see: The installer reports success. Install logs are written to /var/log/install.log. - 3
Or install on Linux
Where: Linux terminal (bash). Use the aarch64 zip on ARM machinesDownload the zip, unzip it and run the installer with sudo. When updating an existing install, use
unzip -uto skip the overwrite prompts.curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/installYou should see: The installer finishes without errors and aws --version (next step) returns a Linux version string. - 4
Check the version
Where: A new terminal window (close and reopen it on Windows to refresh PATH)Type the command below.
aws --versionYou should see: A line such as aws-cli/2.27.41 Python/3.11.6 Windows/10 exe/AMD64 prompt/off. Your version number will be newer. - 5
Configure IAM Identity Center sign-in (recommended)
Where: The same terminal windowRun
aws configure ssoand answer the prompts: a session name, your start URL, the SSO Region andsso:account:accessfor scopes. Your browser opens; approve the request (the client name starts withbotocore-client-). Back in the terminal pick the account and role, then set the default Region, output format and a profile name.aws configure sso # SSO session name (Recommended): contoso-sso # SSO start URL [None]: https://my-sso-portal.awsapps.com/start # SSO region [None]: us-east-1 # SSO registration scopes [None]: sso:account:access # Default client Region [None]: ap-southeast-2 # CLI default output format (json if not specified) [None]: json # Profile name [123456789011_ReadOnly]: contoso-adminYou should see: A [profile contoso-admin] section and an [sso-session contoso-sso] section are written to the config file in the .aws folder in your home directory. - 6
Or configure access keys (long-term credentials)
Where: The same terminal windowOnly if your organisation does not use IAM Identity Center. AWS labels long-term credentials "Not recommended". Run
aws configureand paste your access key ID and secret access key, then a default Region and output format.aws configure # AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE # AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY # Default region name [None]: ap-southeast-2 # Default output format [None]: jsonYou should see: The command returns to the prompt. The credentials and config files are saved in the .aws folder in your home directory (%UserProfile% on Windows, ~ on macOS and Linux). - 7
Confirm who you are signed in as
Where: The same terminal windowRun the command below (drop
--profileif you used aws configure or named the SSO profiledefault).aws sts get-caller-identity --profile contoso-adminYou should see: JSON showing "UserId", "Account" (your 12-digit account ID) and "Arn" for the role or user you expect. - 8
Sign in again when the SSO session expires
Where: The same terminal windowSSO credentials expire and you must renew them by signing in again.
aws sso login --profile contoso-adminYou should see: Successfully logged into Start URL: https://my-sso-portal.awsapps.com/start - 9
Use AWS CloudShell if you cannot install anything
Where: AWS Management Console > CloudShell icon on the navigation bar (or in the console footer)AWS describes CloudShell as a browser-based, pre-authenticated shell with the AWS CLI preinstalled. The credentials you used to sign in to the console are available automatically, so you do not run aws configure.
aws sts get-caller-identityYou should see: A shell opens in the browser and returns your console identity.
Expert tips
Define an [sso-session] block once and point several profiles at it with sso_session, one per account or role. One aws sso login then covers them all, and AWS says the CLI renews the role credentials automatically while the IAM Identity Center session is valid.
Before anything that changes resources, run aws sts get-caller-identity --profile <name> and check the account ID. Working in the wrong account is the most common and most expensive CLI mistake during a migration.
Many "resource not found" errors are simply the wrong region. Set a region for each profile, or change it with aws configure set region ap-southeast-2 --profile <name>, so commands land where your migration target is.
From version 2.22.0 the CLI uses PKCE sign-in by default, which needs a browser on the same machine. On a jump host or server, use aws sso login --profile <name> --use-device-code and open the URL on your own computer.
Run aws sso logout to delete cached SSO credentials (stored under ~/.aws/sso/cache). If you used long-term access keys for a migration, remove them from ~/.aws/credentials and deactivate them in IAM when the project ends.
How to confirm it worked
aws --versionreturnsaws-cli/2.x.x.aws sts get-caller-identity --profile contoso-adminreturns the account ID and role ARN you expect.On macOS,
which awsreturns/usr/local/bin/aws.
How to reverse it
Sign out of SSO with aws sso logout ("Successfully signed out of all SSO profiles."). Delete any access key you created in the IAM console. To remove saved settings, delete the .aws folder in your home directory. To remove the CLI on Windows, uninstall AWS Command Line Interface v2 from Settings > Apps > Installed apps; for macOS and Linux follow the uninstall section of the AWS install page.
Errors you might see
aws: command not found / 'aws' is not recognizedCause: The terminal was open during installation and has not picked up the new PATH.
Fix: Close and reopen the terminal. If it persists, see "Command not found errors" in AWS's CLI troubleshooting guide.
aws --version returns a different version than you installedCause: An older copy of the CLI (for example a version 1 install) appears earlier in PATH.
Fix: Follow AWS's troubleshooting section for this message and remove the older install. On Amazon Linux run sudo yum remove awscli before the first update.
aws --version still returns a version after uninstalling the AWS CLICause: Another copy of the CLI remains on the system or in PATH.
Fix: Follow the matching section of AWS's CLI troubleshooting guide to find and remove the remaining copy.
Browser does not open during aws configure sso (symptom)Cause: No default browser is available, for example over SSH.
Fix: The CLI prints a URL to open manually. Or rerun with --use-device-code, open the URL shown on another device and enter the code.
Commands fail after a few hours with an SSO profile (symptom)Cause: IAM Identity Center credentials have expired; AWS says you must renew them explicitly.
Fix: Run aws sso login --profile contoso-admin again.
Questions
How do I update AWS CLI v2?
From version 2.36.0 you can run aws update (from an elevated shell for all-users installs). You can also rerun the installer.
Should I use aws configure or aws configure sso?
AWS recommends federation through IAM Identity Center over long-term IAM user keys. Use aws configure sso when your organisation has Identity Center.
Where does the AWS CLI store credentials?
In the credentials and config files in the .aws folder in your home directory. You can change the location with AWS_CONFIG_FILE and AWS_SHARED_CREDENTIALS_FILE.
Can I install without admin rights?
Yes. On Windows use AWSCLIV2-User.msi. On Linux run ./aws/install -i /usr/local/aws-cli -b /usr/local/bin with folders you can write to.
Official sources
Vendors change menus and requirements. Confirm on the source before you rely on a detail. Last checked 4 Nov 2026.