【问题标题】:AWS Codecommit - fatal: unable to access : The requested URL returned error: 403AWS Codecommit - 致命:无法访问:请求的 URL 返回错误:403
【发布时间】:2022-07-17 19:43:53
【问题描述】:

在我重新安装 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 访问权限。

我不确定解决它的部分是什么,可能是第一步。

【问题讨论】:

  • 403 是“禁止的”,即您没有权限。检查您的权限。请注意,user.name 和 user.email 不是凭据;您传递给 AWS 的凭证来自 aws codecommit credential-helper。如果您使用的是 macOS,请参阅 docs.aws.amazon.com/codecommit/latest/userguide/…。
  • 我确实检查了权限,它们与我几天前推送更改时的权限相同。此外,关于凭据,我知道姓名和电子邮件不是我进行身份验证所需的凭据。它是用户名和密码,但该命令甚至停止提示我使用我的凭据,这就是它如此令人困惑的原因。
  • 某事发生了变化:要么是您提供给 AWS 的凭证,要么是 AWS 正在进行的验证,或者两者兼而有之。使用 VonC showed 的测试来查看您发送到 AWS 的内容(和/或设置 GIT_TRACE、GIT_PACKET_TRACE、CURL 跟踪等;请参阅 this question)。

标签: git amazon-web-services ubuntu aws-cli aws-codecommit


【解决方案1】:

仔细检查您的 AWS managed policies 是否有 CodeCommit。
如果您的IAM User has switched to ForceMultiFactorAuthentication as policy,则需要使用令牌,而不是密码。

在本地,检查您的凭据管理器存储的密码:

printf "protocol=https\nhost=git-codecommit.eu-west-2.amazonaws.com"|aws codecommit credential-helper get

【讨论】:

  • 我确实检查了我的 AWS 托管策略,但事实并非如此。在这一点上,该命令甚至没有询问我的凭据,所以我认为它与权限无关。
  • 对于存储的密码,我并没有真正得到任何有用的回报。 printf "protocol=https\nhost=git-codecommit.eu-west-2.amazonaws.com"|aws codecommit credential-helper get --> 'path'
【解决方案2】:

我解决问题的方式毕竟是:

Uninstalled aws client from my system and re installed and configured it from scratch.
I cloned my IAM account and gave it Full AWSCodeCommit access.

我不确定解决它的部分是什么,这可能是我重新安装所有内容后的第一步,再次提示我使用我的凭据。

【讨论】:

    【解决方案3】:

    只需删除凭据如下,下次弹出窗口提示输入凭据 删除凭据管理器的步骤

    控制面板 选择“凭据管理器” 在通用凭据下,删除相应的 Git 凭据。

    【讨论】:

      猜你喜欢
      • 2019-01-28
      • 2021-08-17
      • 2016-12-05
      • 1970-01-01
      • 2023-03-17
      • 1970-01-01
      • 2020-08-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多