简体   繁体   English

如何使用IAM访问ID和密钥对AWS CodeCommit git repo进行身份验证?

[英]How to authenticate against AWS CodeCommit git repo with IAM access id and secret key?

Is it possible to authenticate to a Git repo with an IAM user access key id and access secret key? 是否可以使用IAM用户访问密钥ID和访问密钥对Git存储库进行身份验证?

I'm trying this by using the access id as the username and the secret as the password, but getting a 403 error returned when I try to clone a repo. 我正在通过使用访问ID作为用户名和密码作为密码来尝试此操作,但是在尝试克隆存储库时返回403错误。

在此处输入图片说明

I have verified the user is in a group that has access to the repository. 我已验证用户属于有权访问存储库的组。 I'm using Git BASH in the screenshot above. 我在上面的屏幕截图中使用Git BASH

Background on Use Case I'm considering developing a service where users can push Single Page Apps (SPA) and Functions to a private Git repository and the service will deploy the functions to Lambda / Azure Functions, deploy the SPA to a CDN, and set up a global load balancer for the functions, and create SSL certificates automatically. 用例背景我正在考虑开发一种服务,用户可以将单页应用程序(SPA)和功能推送到私有Git存储库中,并且该服务会将功能部署到Lambda / Azure功能,将SPA部署到CDN并设置为这些功能设置一个全局负载平衡器,并自动创建SSL证书 Basically I want to make is super easy for developers to deploy world class / world scale web site/services for super cheap. 基本上,我想让开发人员以超级便宜的价格轻松部署世界一流的/世界规模的网站/服务。 To kick this process off I need a way to get the code, so my thinking is provision a private repository for each user and let them push code there. 要启动此过程,我需要一种获取代码的方法,因此我的想法是为每个用户提供一个私有存储库,然后让他们将代码推送到那里。 I'm looking for something similar to what AppHarbor does , just push to Git with your credentials. 我正在寻找类似于AppHarbor所做的事情,只需使用您的凭据推送到Git。

No, you cannot use the Access Key and Secret Key in Git like this directly. 不,您不能像这样直接在Git中使用访问密钥和秘密密钥。

Instead, you first: 相反,您首先:

  1. Configure AWS CLI with your access key and secret key using aws configure , then 使用aws configure使用您的访问密钥和aws configure密钥配置AWS CLI,然后
  2. Use git config to get your Git credentials. 使用git config获取您的Git凭据。

For example: 例如:

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

Source: http://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-https-unixes.html 来源: http//docs.aws.amazon.com/codecommit/latest/userguide/setting-up-https-unixes.html

CodeCommit uses credential helper to authenticate Git operations and requires a Git config change as Matt mentioned. CodeCommit使用凭据助手来验证Git操作,并且需要更改Matt提到的Git配置。 @Paul can you please share if you have a use case for using Secret Key / Access Key to authenticate Git requests on CodeCommit? @Paul,如果您有使用秘密密钥/访问密钥在CodeCommit上对Git请求进行身份验证的用例,可以分享一下吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM