如何清除 AWS 配置中的凭据?

我已经删除了 sudo nano ~/.aws/config中的 AWS 认证。但是,凭证仍然在 aws configure。有没有办法重置 aws configure的清晰状态?

134584 次浏览

just remove ~/.aws/credentials along with ~/.aws/config

EDIT: Note path references user home directory and specific to each user in system.

Do not delete the files if you have multiple profiles created as all will be lost if you delete these files! unless thats what you want :)

Go to each of the file -

 - ~/.aws/credentials
- ~/.aws/config

and remove just the part profiles you want to delete. Eg.

~/.aws/credentials

[default]
aws_access_key_id=yourAccessKeyId
aws_secret_access_key=yourSecretAccessKey


[user2]
aws_access_key_id=yourAccessKeyId
aws_secret_access_key=yourSecretAccessKey

and

~/.aws/config

[default]
region=us-west-2
output=json


[profile user2]
region=us-east-1
output=text

Just delete entries corresponding to user2 profile if thats what you want. And you should also give a profile name to profile you configure -

aws configure --profile user2

Else it will just be [default]

More details - http://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html

Here is the graphical presentation for mac user Graphical

Not sure if this clears the credentials but I was able to simply change the credentials by running aws configure again and entering in new credentials. I was also able to make multiple profiles by running aws configure --newusername and I could run a future command with that user by appending --profile newusername. Good tutorial here: https://www.crybit.com/configure-iam-user-on-your-linux-machine/

Maybe just a Windows thing but if you edit the ~.\aws\config and ~.\aws\credentials files like is suggested by Aniket Thakur, you might run into an issue where aws configure complains about a profile you deleted not being available. This seems to be because the AWS_PROFILE environment variable is referencing that profile. Unset that variable and you should be back in business.

Tried to comment under his answer but I don't have enough points (on this account).

For windows users just open aws credentials file and update based on your requirements.

File is located in C:> Users > yourusername > .aws - credentials

All the best.