在重新安装 aws-cli
后,我无法从我的 AWS CodeCommit 存储库中拉取和/或推送更新。我尝试了所有我能找到的建议解决方案,但似乎都不起作用。
我正在使用 Ubuntu 21.10,并安装了:
$ aws --v
aws-cli/1.19.1 Python/3.9.7 Linux/5.13.0-41-generic botocore/1.20.0
git version 2.32.0
我遇到的错误是:
fatal: unable to access 'https://git-codecommit.eu-west-2.amazonaws.com/v1/repos/myrepo/': The requested URL returned error: 403
以前它会要求我输入用户名和密码,但是在我尝试解决这个问题后,它完全停止要求我的凭据。无论如何,我确认我使用了正确的凭据。此外,我在AWS上拥有必要的权限。直到几个小时之前,我都成功地拉取和推送更新。
按照大多数在线解决方案的建议,aws凭证助手已经设置好了。更具体地说,我的.gitconfig
文件如下:
[user]
name = My_name
email = My_email
[credential]
helper = !aws codecommit credential-helper $@
UseHttpPath = true
此外,我正确地设置了$ aws configure
配置(使用正确的区域)。
运行 $ git config --list --show-origin
命令后,我得到了以下内容:
file:/etc/gitconfig user.email=My_email
file:/home/f_user/.gitconfig user.name=My_name
file:/home/f_user/.gitconfig user.email=My_email
file:/home/f_user/.gitconfig credential.helper=!aws codecommit credential-helper $@
file:/home/f_user/.gitconfig credential.usehttppath=true
说实话我不知道还可以尝试什么,非常感谢任何帮助!
编辑: 我解决问题的方法是:
- 从系统中卸载了aws客户端并重新安装并从头开始配置。
- 克隆了我的IAM帐户并授予了完全的AWSCodeCommit访问权限。
我不确定哪一步解决了问题,可能是第一步。
user.name
和user.email
不是凭据;您传递给AWS的凭据来自于aws codecommit credential-helper
。如果您使用的是macOS,请参阅https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-https-unixes.html。 - torek