{"id":41589,"date":"2026-11-21T22:05:37","date_gmt":"2026-11-21T22:05:37","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=41589"},"modified":"2026-11-21T22:05:37","modified_gmt":"2026-11-21T22:05:37","slug":"aws-tutorials-install-and-configure-aws-cli","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/aws-tutorials-install-and-configure-aws-cli\/","title":{"rendered":"AWS Tutorials: Install and Configure AWS CLI"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This guide covers installing AWS CLI version 2 on CentOS\/RHEL, Ubuntu, other Linux distributions, macOS and Windows, then setting up credentials and checking that the CLI is talking to the right AWS account. The commands in the original post are completed and corrected below, and the sections after them cover profiles, SSO sign-in, updates and the errors people run into most often.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install AWS CLi in CENTOS\/RHEL<\/h2>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">$ sudo yum remove awscli<\/code><\/span><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Install AWS CLi in Ubuntu<\/h2>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">$ sudo apt-<span class=\"hljs-keyword\">get<\/span> install awscli\n\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Install AWS CLi in Linux using Package<\/h2>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">curl <span class=\"hljs-string\">\"https:\/\/awscli.amazonaws.com\/awscli-exe-linux-x86_64.zip\"<\/span> -o <span class=\"hljs-string\">\"awscliv2.zip\"<\/span>\r\nunzip awscliv2.zip\r\nsudo .\/aws\/install\r\nsudo .\/aws\/install --bin-dir \/usr\/local\/bin --install-dir \/usr\/local\/aws-cli --update\r\nwhich aws\r\nls -l \/usr\/local\/bin\/aws\r\naws --version<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Install AWS CLi in Windows<\/h2>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">DOWNLOAD - https:<span class=\"hljs-comment\">\/\/awscli.amazonaws.com\/AWSCLIV2.msi<\/span>\r\n\r\nmsiexec.exe \/i https:<span class=\"hljs-comment\">\/\/awscli.amazonaws.com\/AWSCLIV2.msi<\/span>\r\nmsiexec.exe \/i https:<span class=\"hljs-comment\">\/\/awscli.amazonaws.com\/AWSCLIV2.msi \/qn<\/span>\r\naws --version\r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Configure AWS and Verify Login<\/h2>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">$ aws configure\r\nAWS Access Key ID &#91;None]: your-access-key-id\r\nAWS Secret Access Key &#91;None]: your-secret-access-key\r\n<span class=\"hljs-keyword\">Default<\/span> region name &#91;None]: region-to-<span class=\"hljs-keyword\">use<\/span> (<span class=\"hljs-title\">e<\/span>.<span class=\"hljs-title\">g<\/span> <span class=\"hljs-title\">us<\/span>-<span class=\"hljs-title\">west<\/span>-2, <span class=\"hljs-title\">us<\/span>-<span class=\"hljs-title\">west<\/span>-1, <span class=\"hljs-title\">etc<\/span>).\r\n<span class=\"hljs-title\">Default<\/span> <span class=\"hljs-title\">output<\/span> <span class=\"hljs-title\">format<\/span> &#91;<span class=\"hljs-title\">None<\/span>]:\r\n\r\n$ <span class=\"hljs-title\">aws<\/span> <span class=\"hljs-title\">s3<\/span> <span class=\"hljs-title\">ls<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Corrections to the commands above<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The commands above get you most of the way, but a few of them are mislabelled or out of date. The table lists each problem and the fix.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Original<\/th><th>Problem<\/th><th>Use instead<\/th><\/tr><\/thead><tbody><tr><td><code>sudo yum remove awscli<\/code> under &quot;Install on CentOS\/RHEL&quot;<\/td><td>This command <strong>removes<\/strong> the old AWS CLI v1 package. It doesn&#039;t install anything.<\/td><td>Remove v1 first if it&#039;s there, then use the official v2 installer (see the next section).<\/td><\/tr><tr><td><code>sudo apt-get install awscli<\/code> on Ubuntu<\/td><td>On older releases this installs AWS CLI <strong>v1<\/strong>, which is outdated. On newer releases such as Ubuntu 24.04 the package may not exist at all.<\/td><td>Use the official v2 installer, or <code>sudo snap install aws-cli --classic<\/code>.<\/td><\/tr><tr><td>Running <code>sudo .\/aws\/install<\/code> and then <code>sudo .\/aws\/install ... --update<\/code><\/td><td>The second command is only for upgrading an existing install. Running both straight after each other does the same job twice.<\/td><td>Use <code>sudo .\/aws\/install<\/code> for a new install. Use <code>sudo .\/aws\/install --update<\/code> when upgrading.<\/td><\/tr><tr><td>x86_64 download URL only<\/td><td>The x86_64 package won&#039;t run on ARM machines such as Graviton.<\/td><td>On ARM, use <code>awscli-exe-linux-aarch64.zip<\/code>.<\/td><\/tr><tr><td>Checking access with <code>aws s3 ls<\/code><\/td><td>Needs the <code>s3:ListAllMyBuckets<\/code> permission and prints nothing if the account has no buckets, so it doesn&#039;t prove much either way.<\/td><td>Use <code>aws sts get-caller-identity<\/code>, which needs no special permissions.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> The headings above say &quot;AWS CLi&quot;. The correct name is AWS CLI (Command Line Interface).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install AWS CLI v2 on Linux (RHEL, CentOS, Ubuntu, Debian)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The bundled installer from AWS works on any glibc-based Linux distribution and always gives you the current v2 release. You need <code>curl<\/code> and <code>unzip<\/code>. Remove any v1 package first so that two versions don&#039;t end up competing on your <code>PATH<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># RHEL \/ CentOS \/ Rocky \/ Alma: remove v1, install prerequisites<\/span>\nsudo yum remove -y awscli\nsudo yum install -y curl unzip\n\n<span class=\"hljs-comment\"># Ubuntu \/ Debian: remove v1, install prerequisites<\/span>\nsudo apt-get remove -y awscli\nsudo apt-get update &amp;&amp; sudo apt-get install -y curl unzip\n\n<span class=\"hljs-comment\"># Pick the package that matches your CPU architecture<\/span>\nARCH=$(uname -m)   <span class=\"hljs-comment\"># x86_64 or aarch64<\/span>\ncurl <span class=\"hljs-string\">\"https:\/\/awscli.amazonaws.com\/awscli-exe-linux-${ARCH}.zip\"<\/span> -o awscliv2.zip\nunzip -q awscliv2.zip\nsudo .\/aws\/install\n\n<span class=\"hljs-comment\"># Verify<\/span>\nhash -r\nwhich aws\naws --version<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">By default the installer puts the files in <code>\/usr\/local\/aws-cli<\/code> and creates a symlink at <code>\/usr\/local\/bin\/aws<\/code>. <code>hash -r<\/code> clears the shell&#039;s cache of command locations, so the shell doesn&#039;t keep running an old <code>aws<\/code> it found earlier. The version output looks something like this (your version numbers will be different):<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">aws-cli\/2.x.x Python\/3.x.x Linux\/6.x.x exe\/x86_64.ubuntu.24<\/code><\/span><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Amazon Linux 2023 comes with AWS CLI v2 already installed. Amazon Linux 2 comes with v1. Run <code>aws --version<\/code> before installing anything.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install on macOS and Windows<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">On macOS, use the official package installer. It works on both Intel and Apple silicon Macs:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">curl <span class=\"hljs-string\">\"https:\/\/awscli.amazonaws.com\/AWSCLIV2.pkg\"<\/span> -o AWSCLIV2.pkg\nsudo installer -pkg AWSCLIV2.pkg -target \/\naws --version<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">On Windows, the <code>msiexec<\/code> commands above work as written. <code>\/qn<\/code> runs the install silently with no prompts, which suits scripts and image builds. Run it from an elevated (administrator) prompt. Once it finishes, <strong>open a new terminal<\/strong> so the updated <code>PATH<\/code> takes effect, then check the version:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">msiexec.exe \/i https:<span class=\"hljs-comment\">\/\/awscli.amazonaws.com\/AWSCLIV2.msi \/qn<\/span>\n<span class=\"hljs-comment\"># open a new PowerShell window, then:<\/span>\naws --version<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">What aws configure writes, and how profiles work<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>aws configure<\/code> saves your answers in two plain-text files in your home directory. If you leave the output format blank, the CLI uses <code>json<\/code>. Other valid formats are <code>yaml<\/code>, <code>text<\/code> and <code>table<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># ~\/.aws\/credentials<\/span>\n&#91;<span class=\"hljs-keyword\">default<\/span>]\naws_access_key_id = AKIA...\naws_secret_access_key = ...\n\n<span class=\"hljs-comment\"># ~\/.aws\/config<\/span>\n&#91;<span class=\"hljs-keyword\">default<\/span>]\nregion = us-east<span class=\"hljs-number\">-1<\/span>\noutput = json<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">If you work with more than one account or role, give each one a named profile. Choose a profile per command with <code>--profile<\/code>, or for the whole shell session with the <code>AWS_PROFILE<\/code> environment variable:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">aws configure --profile dev\naws s3 ls --profile dev\n\nexport AWS_PROFILE=dev\naws configure <span class=\"hljs-keyword\">list<\/span>          <span class=\"hljs-comment\"># shows the active profile, region and where each value came from<\/span>\naws configure <span class=\"hljs-keyword\">list<\/span>-profiles<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Environment variables override both files. This is the usual way to pass credentials in CI pipelines and containers. The main ones are <code>AWS_ACCESS_KEY_ID<\/code>, <code>AWS_SECRET_ACCESS_KEY<\/code>, <code>AWS_SESSION_TOKEN<\/code> (for temporary credentials) and <code>AWS_REGION<\/code> or <code>AWS_DEFAULT_REGION<\/code>. On EC2, ECS and Lambda, attach an IAM role to the resource instead. The CLI picks up the role&#039;s credentials automatically, so you don&#039;t need to configure anything.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Recommended: sign in with IAM Identity Center instead of access keys<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>aws configure<\/code> example above uses long-term IAM user access keys. AWS recommends temporary credentials wherever possible. If your organisation uses IAM Identity Center, set up an SSO profile once and then sign in through your browser whenever the session expires:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">aws configure sso\n<span class=\"hljs-comment\"># SSO session name: my-sso<\/span>\n<span class=\"hljs-comment\"># SSO start URL: https:\/\/your-portal.awsapps.com\/start<\/span>\n<span class=\"hljs-comment\"># SSO region: us-east-1<\/span>\n<span class=\"hljs-comment\"># (a browser window opens; approve the request, then choose account and role)<\/span>\n\naws sso login --profile my-dev-profile\naws sts get-caller-identity --profile my-dev-profile<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">To set up the portal and permission sets this depends on, see <a href=\"https:\/\/www.devopsschool.com\/blog\/aws-tutorials-aws-identity-center-guide\/\">AWS Identity Center Guide<\/a> and <a href=\"https:\/\/www.devopsschool.com\/blog\/complete-guide-of-aws-organization-and-aws-access-portal\/\">AWS Organization and AWS access portal<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Verify, update and uninstall<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>aws sts get-caller-identity<\/code> is the most reliable check. It returns the account and identity the CLI is using, and it works even when that identity has no permissions at all:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">$ aws sts <span class=\"hljs-keyword\">get<\/span>-caller-identity\n{\n    <span class=\"hljs-string\">\"UserId\"<\/span>: <span class=\"hljs-string\">\"AIDA...\"<\/span>,\n    <span class=\"hljs-string\">\"Account\"<\/span>: <span class=\"hljs-string\">\"123456789012\"<\/span>,\n    <span class=\"hljs-string\">\"Arn\"<\/span>: <span class=\"hljs-string\">\"arn:aws:iam::123456789012:user\/devops-user\"<\/span>\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">To update on Linux, download the latest zip again and run the installer with <code>--update<\/code>. To uninstall, delete the symlinks and the install directory:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Update<\/span>\ncurl <span class=\"hljs-string\">\"https:\/\/awscli.amazonaws.com\/awscli-exe-linux-$(uname -m).zip\"<\/span> -o awscliv2.zip\nunzip -qo awscliv2.zip\nsudo .\/aws\/install --update\n\n<span class=\"hljs-comment\"># Uninstall<\/span>\nsudo rm \/usr\/local\/bin\/aws \/usr\/local\/bin\/aws_completer\nsudo rm -rf \/usr\/local\/aws-cli<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Common errors and fixes<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Error<\/th><th>Likely cause<\/th><th>Fix<\/th><\/tr><\/thead><tbody><tr><td><code>aws: command not found<\/code><\/td><td><code>\/usr\/local\/bin<\/code> isn&#039;t on your <code>PATH<\/code>, or the shell has cached an old location.<\/td><td>Run <code>hash -r<\/code>, check <code>echo $PATH<\/code>, or reinstall with <code>--bin-dir<\/code> set to a directory that is on your <code>PATH<\/code>.<\/td><\/tr><tr><td><code>aws --version<\/code> still shows <code>aws-cli\/1.x<\/code><\/td><td>The v1 package (or a pip install of v1) appears earlier on your <code>PATH<\/code>.<\/td><td>Run <code>which -a aws<\/code>, then remove v1 with yum, apt or <code>pip uninstall awscli<\/code>.<\/td><\/tr><tr><td><code>unzip: command not found<\/code><\/td><td>The prerequisite isn&#039;t installed.<\/td><td><code>sudo yum install -y unzip<\/code> or <code>sudo apt-get install -y unzip<\/code>.<\/td><\/tr><tr><td><code>Unable to locate credentials<\/code><\/td><td>No credentials in any profile, environment variable or instance role.<\/td><td>Run <code>aws configure<\/code> or <code>aws sso login<\/code>, or attach an IAM role to the instance.<\/td><\/tr><tr><td><code>InvalidClientTokenId<\/code> or <code>SignatureDoesNotMatch<\/code><\/td><td>The key was copied wrongly, has been deactivated, or the system clock is off.<\/td><td>Create a new key pair and sync the clock with NTP (<code>timedatectl<\/code>).<\/td><\/tr><tr><td><code>You must specify a region<\/code><\/td><td>No region set in the profile or the environment.<\/td><td>Set <code>region<\/code> in <code>~\/.aws\/config<\/code>, export <code>AWS_REGION<\/code>, or pass <code>--region<\/code>.<\/td><\/tr><tr><td><code>AccessDenied<\/code> on <code>aws s3 ls<\/code><\/td><td>The credentials work but the identity has no S3 permission.<\/td><td>Run <code>aws sts get-caller-identity<\/code> to confirm the identity, then grant only the permissions it needs.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Security best practices<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use IAM Identity Center or IAM roles instead of long-term access keys. Never create access keys for the root user.<\/li>\n\n\n<li>If you have to use access keys, rotate them regularly and give the IAM user least-privilege policies.<\/li>\n\n\n<li>Never commit <code>~\/.aws\/credentials<\/code> to Git or bake it into container images. In pipelines, pass credentials as secrets or environment variables.<\/li>\n\n\n<li>Restrict the credentials file to your own user: <code>chmod 600 ~\/.aws\/credentials<\/code>.<\/li>\n\n\n<li>Use separate named profiles for dev and prod, and check which one is active with <code>aws configure list<\/code> before you run commands that change anything.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Should I install AWS CLI v1 or v2?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Install v2. It&#039;s the current major version, ships with its own Python runtime, and supports IAM Identity Center (SSO) sign-in. Only use v1 if you&#039;re stuck with legacy scripts that depend on it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do I check which AWS account the CLI is using?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run <code>aws sts get-caller-identity<\/code>. It prints the account ID and ARN for the active credentials. Run <code>aws configure list<\/code> to see which profile and region are in use and where each value came from.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Where does the AWS CLI store credentials?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Access keys go in <code>~\/.aws\/credentials<\/code> and settings such as region and output format go in <code>~\/.aws\/config<\/code>. On Windows these live in <code>%USERPROFILE%\\.aws\\<\/code>. Environment variables override both files.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why does apt install an old AWS CLI on Ubuntu?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The Ubuntu <code>awscli<\/code> package is the v1 CLI, and on recent Ubuntu releases it may not be available at all. Use the official bundled installer from AWS, or <code>sudo snap install aws-cli --classic<\/code>, to get v2.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do I use multiple AWS accounts with the CLI?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create a named profile for each account with <code>aws configure --profile name<\/code> or <code>aws configure sso<\/code>. Then pass <code>--profile name<\/code> on each command, or export <code>AWS_PROFILE=name<\/code> for the whole shell session.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related tutorials<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/aws-tutorials-aws-identity-center-guide\/\">AWS Tutorials: AWS Identity Center Guide<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/complete-guide-of-aws-organization-and-aws-access-portal\/\">Complete Guide of AWS Organization and AWS access portal<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/aws-commands-line-reference-aws-eks\/\">AWS Commands Line Reference: aws eks<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/category\/cloud-computing\/aws\/\">More AWS tutorials<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This guide covers installing AWS CLI version 2 on CentOS\/RHEL, Ubuntu, other Linux distributions, macOS and Windows, then setting up credentials and checking that the CLI is&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5633],"tags":[1392],"class_list":["post-41589","post","type-post","status-publish","format-standard","hentry","category-aws","tag-aws-cli"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/41589","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=41589"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/41589\/revisions"}],"predecessor-version":[{"id":80097,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/41589\/revisions\/80097"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=41589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=41589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=41589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}