How to Clear your AWS CLI Credentials
Clear your AWS CLI Credentials
In order to clear your AWS CLI Credentials you have to:
Locate the
credentialsandconfigfiles. The path depends on your operating system:
shell
# on Linux and macOS
~/.aws/credentials
~/.aws/config
# on Windows
C:\Users\USERNAME\.aws\credentials
C:\Users\USERNAME\.aws\configOpen the files in a text editor and remove the unnecessary profiles. A profile's configuration is split between the
credentialsandconfigfiles in the following way:
credentials
[default]
aws_access_key_id=YOUR_ACCESS_KEY_ID
aws_secret_access_key=YOUR_SECRET_ACCESS_KEY
[admin]
aws_access_key_id=YOUR_ACCESS_KEY_ID
aws_secret_access_key=YOUR_SECRET_ACCESS_KEYconfig
[default]
region = us-east-1
output=json
[profile admin]
region=us-east-1
output=jsonOnce the unnecessary profiles are deleted from your
credentialsandconfigfiles, save the changes and the profile is removed from your machine
If your credentials and config files contain a single profile, you can just delete the files to clear your AWS CLI credentials. The next time you run the aws configure command, the AWS CLI will automatically re-create them for you.
Be sure to delete any configuration referencing a profile from both files - credentials and config.
The next time you need to add your AWS CLI credentials, you can run the aws configure command to either add a profile to the list or re-create the config and credentials files on your machine:
shell
# For the Default profile
aws configure
# For a profile named admin
aws configure --profile adminThe access and secret access keys will be stored in the credentials file, whereas the region and output format will be in the config file.
参考资料
最后更新于