由于许可政策,我们的组织无法使用适用于 Windows 的 Docker Desktop。我们在 Ubuntu 22.04 WSL2 中使用 Docker 控制台。因此,在使用 AWS ECR 之前,我在 Ubuntu 22.04 中工作。具有相同的凭证
aws_access_key_id
和 aws_secret_access_key
,区域 eu-central-1
:
在 Windows 10 上,cmd
Microsoft Windows [Version 10.0.19045.3803]
(c) Microsoft Corporation. All rights reserved.
C:\Users\dnvy>aws s3 ls
2023-11-10 00:32:35 aws-landing-zone-local-cf-logs-053297099947-eu-central-1
2023-11-10 00:32:19 aws-landing-zone-local-cf-logs-053297099947-eu-west-1
2023-11-10 00:32:35 aws-landing-zone-local-elb-logs-053297098447-eu-central-1
2023-11-10 00:32:19 aws-landing-zone-local-elb-logs-053297098447-eu-west-1
2023-11-10 00:32:02 aws-landing-zone-local-s3-access-logs-099997098447-eu-central-1
2023-11-10 00:31:55 aws-landing-zone-local-s3-access-logs-053297098447-eu-west-1
2023-11-10 00:32:35 aws-landing-zone-local-waf-logs-053297099947-eu-central-1
2023-11-10 00:32:19 aws-landing-zone-local-waf-logs-053297098997-eu-west-1
2023-12-11 09:30:56 xxaxx-app-bucket
2023-12-11 08:06:33 xxxxx-xxth
2023-12-11 22:36:51 serverless-xxxxxx-dev-serverlessdeploymentbucket-xxsjpddxx3gi
2023-12-11 20:55:51 serverless-next-dev-serverlessdeploymentbucket-ljbtxxagtmsk
2023-12-13 00:43:50 www.yyas33-xxv.xxxllixx44.net
C:\Users\dnvy>
成功了。
在 Ubuntu 22.04 WSL 2 上(Windows 10 内)(为了安全起见,我修改了密钥,它不是真正的凭据)
root@WS0419:~# aws configure
AWS Access Key ID [****************SI1X]: XXIAQY2GBF3HQNXXSI1X
AWS Secret Access Key [****************icEh]: 9Lx+HhgSxDucxZ0TvAgvr5kG2uqebx3WBYggicEh
Default region name [eu-central-1]: eu-central-1
Default output format [json]: json
root@WS0419:~# aws s3 ls
An error occurred (InvalidToken) when calling the ListBuckets operation: The provided token is malformed or otherwise invalid.
root@WS0419:~# aws
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: the following arguments are required: command
root@WS0419:~#
失败了。
如何在 Ubuntu 22.04 WSL2 中成功登录 AWS CLI?
前往
~/.aws/credentials
在文件
credentials
中,删除 aws_session_token
(键和值)。然后
aws configure
重新输入凭据。