{"id":4489,"date":"2025-11-21T20:36:25","date_gmt":"2025-11-21T20:36:25","guid":{"rendered":"https:\/\/www.itersdesktop.com\/?p=4489"},"modified":"2025-11-21T20:50:57","modified_gmt":"2025-11-21T20:50:57","slug":"how-to-manage-multiple-aws-keys-on-localhost","status":"publish","type":"post","link":"https:\/\/www.itersdesktop.com\/fr\/2025\/11\/21\/how-to-manage-multiple-aws-keys-on-localhost\/","title":{"rendered":"How to manage multiple AWS keys on localhost"},"content":{"rendered":"To manage multiple AWS keys on localhost, configure multiple profiles in the AWS CLI using the ~\/.aws\/config and ~\/.aws\/credentials files.<br \/><br \/>Obtain Access Keys:<br \/>Navigate to the AWS Management Console and create access keys for each AWS account you want to manage. Make sure to save both the Access Key ID and Secret Access Key for each account.<br \/>Configure AWS CLI Profiles:<br \/>Open your terminal and run the following command to configure a profile for each account:<br \/>aws configure &#8211;profile profile_name<br \/>Replace profile_name with a meaningful name for the profile (e.g., dev, prod). You will be prompted to enter the Access Key ID, Secret Access Key, region, and output format for that profile.<br \/>Edit Configuration Files:<br \/>The AWS CLI creates two files in your home directory:<br \/>~\/.aws\/credentials: This file contains your access keys.<br \/>~\/.aws\/config: This file contains configuration settings like the default region and output format.<br \/>You can manually edit these files to add or modify profiles. For example, your ~\/.aws\/credentials file might look like this:<br \/>[dev]<br \/>aws_access_key_id = YOUR_DEV_ACCESS_KEY<br \/>aws_secret_access_key = YOUR_DEV_SECRET_KEY<br \/>[prod]<br \/>aws_access_key_id = YOUR_PROD_ACCESS_KEY<br \/>aws_secret_access_key = YOUR_PROD_SECRET_KEY<br \/>And your ~\/.aws\/config file might look like this:<br \/>[profile dev]<br \/>region = us-west-2<br \/>output = json<br \/>[profile prod]<br \/>region = us-east-1<br \/>output = json<br \/>Using the Profiles:<br \/>When running AWS CLI commands, specify the profile you want to use with the &#8211;profile flag. For example:<br \/>aws s3 ls &#8211;profile dev<br \/>If you set a default profile, you can run commands without specifying the &#8211;profile flag.<br \/>Environment Variables (Optional):<br \/>You can also set environment variables to temporarily override the profile settings. For example:<br \/>export AWS_PROFILE=dev<br \/>This will set the dev profile as the active profile for your terminal session.<br \/>Best Practices<br \/>Security: Ensure that your ~\/.aws\/credentials file has appropriate permissions (e.g., chmod 600 ~\/.aws\/credentials) to prevent unauthorized access.<br \/>Key Rotation: Regularly rotate your access keys and remove any keys that are no longer in use to enhance security. <br \/>3<br \/><br \/>By following these steps, you can effectively manage multiple AWS keys on your localhost, allowing for seamless interaction with different AWS accounts and environments.<br \/><br \/>References<br \/>[1] https:\/\/bobbyhadz.com\/blog\/aws-cli-manage-multiple-accounts<br \/>[2] https:\/\/dev.to\/pragnesh_patel\/configuring-multiple-aws-cli-profiles-4el4<br \/>[3] https:\/\/devtoolhub.com\/manually-setting-up-multiple-aws-accounts-for-cli\/<br \/>","protected":false},"excerpt":{"rendered":"<p>To manage multiple AWS keys on localhost, configure multiple profiles in the AWS CLI using the ~\/.aws\/config and ~\/.aws\/credentials files.Obtain Access Keys:Navigate to the AWS Management Console and create access&hellip; <\/p>\n","protected":false},"author":2,"featured_media":4493,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[722],"tags":[876],"class_list":["post-4489","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","tag-aws"],"_links":{"self":[{"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/posts\/4489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/comments?post=4489"}],"version-history":[{"count":4,"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/posts\/4489\/revisions"}],"predecessor-version":[{"id":4495,"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/posts\/4489\/revisions\/4495"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/media\/4493"}],"wp:attachment":[{"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/media?parent=4489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/categories?post=4489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itersdesktop.com\/fr\/wp-json\/wp\/v2\/tags?post=4489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}