0

我已经设置了一个 EC2 实例,给它一个具有 IAM 角色的实例配置文件,该角色允许它访问我的 codecommit 存储库,现在我正在尝试使用 git 从中提取。由于我使用的是 iam 角色的临时凭据,因此我没有凭据配置文件……但这应该没问题。

我试过了:

git config --global credential.helper '!aws codecommit credential-helper $@'

但这不起作用

如果我将以下内容放入文件中,请说“repodesc”

protocol=https
path=/v1/repos/reponame
host=git-codecommit.us-east-1.amazonaws.com'

然后运行

cat repodesc | aws codecommit credential-helper get

它给我发回一个临时的用户名和密码......所以我知道这是有效的......

因此,我尝试使用它:

git pull https://user:pass@git-codecommit.us-east-1.amazonaws.com/v1/repos/reponame

但这失败了。说格式不对。

我不想用 ssh 来做这件事,因为它破坏了临时凭证的全部意义。我想以正确的方式做到这一点。但这很令人生气。

我已经看了一百万次过于冗长的亚马逊文档,似乎无法找到答案所在的页面。

任何帮助将不胜感激。我真的是在拔头发。

4

1 回答 1

1

找到了解决方案

问题出在 git 和 ubuntu14.04 上。似乎默认包使用 gnutls 进行身份验证,而不是 openssl,并且它不能很好地处理代理。所以我不得不用 libcurl4-openssl-dev 重建 git。解决方案以及详细的构建说明来自这里:

https://askubuntu.com/questions/186847/error-gnutls-handshake-failed-when-connecting-to-https-servers

一旦建成,我所要做的就是像以前一样:

git config --global credential.helper '!aws codecommit credential-helper $@'
git pull https://git-codecommit.us-east-1.amazonaws.com/v1/repos/reponame master

(或者使用 git clone 如果你喜欢的话)

据我所知,重建有点难看,这并不是真正的解决方案。如果我发现更优雅的东西,我会更新它。

于 2016-04-14T22:26:59.150 回答