Vie*_*van 18 git amazon-web-services aws-codecommit
我的本地笔记本电脑是Mac.
正确配置了ssh密钥.这是〜/ .ssh/config的内容
Host barthea
Hostname git-codecommit.us-east-1.amazonaws.com
User AVVVVVVVVVVVVVVVVVQ
IdentityFile ~/.ssh/aws-aws.pem
跑ssh barthea得到了我
`You have successfully authenticated over SSH. You can use Git to interact with AWS CodeCommit. Interactive shells are not supported.Connection to git-codecommit.us-east-1.amazonaws.com closed by remote host.
Run Code Online (Sandbox Code Playgroud)
`2.我创建了一个带有密码和访问密钥的IAM用户bruce666,使该用户成为"团队"组的一部分.然后我创建了一个包含"AWSCodeCommitPowerUsers"的策略,并将此策略分配给"团队".最后将bruce666分配给"团队".此时,bruce666可以通过管理控制台访问CodeCommit中的任何仓库.
我运行了aws config --profile bruce666,用他的访问和密钥,他的区域和json指定格式.此时,我能够通过运行aws codecommit get-repository --repository-name rekha --profile bruce666在CodeCommmit中创建rekha repo.
我可以创建几个虚拟文件,运行git init,git add.,git的承诺-m"1",GIT中添加初始https://git-gitcode.amzonaws.com/repos/v1/rekha,混帐推-u主产地和该动作会成功.
但是,当我运行git clone ssh://git-gitcode.amazonaws.com/repos/v1/rekha时,我得到"致命:无法访问" https://git-codecommit.us-east-1.amazonaws. com/v1/repos/barthia / ':请求的URL返回错误:403"是什么给出的?
use*_*316 30
在MAC上,如果上述技巧不起作用,请执行以下操作:
现在再试一次.它应该工作.当您遇到错误403时,您可能还必须在下次再次执行此操作.
irf*_*csd 11
在Windows中使用git push命令时,我也遇到相同的403错误。我完成了AWS文档中提到的所有设置,但未解决我的问题。在我查看了通过Windows凭据设置的git凭据后,如屏幕所示。我发现它设置了访问密钥/秘密密钥,而不是git https凭据(不知道如何)。
单击编辑链接,使用为AWS User生成的正确git凭证更新凭证,一切正常。
我解决了。
403 错误消息是一条专门的 Git 错误消息。我添加了两个 AWS 指定的帮助程序命令:
git config --global credential.helper '!aws --profile bruce666 codecommit credential-helper $@'
git config --global credentials.helper UseHttpPath=true
Run Code Online (Sandbox Code Playgroud)
这解决了这个问题。
本地目录中的.git/config文件(在克隆刚刚创建的 Codecommit 存储库之前,应如下所示:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = false
[credential]
helper = !aws --profile bruce666 codecommit credential-helper $@
UseHttpPath = true
[remote "origin"]
url = https://git-codecommit.us-east-1.amazonaws.com/v1/repos/barthea
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
Run Code Online (Sandbox Code Playgroud)
如.git/config文件中所指定,您是使用 https 而不是 ssh 进行克隆。我一定没有使用 OSX 附带的默认 git 版本,因为我没有遇到任何工具链问题。
运行以下命令后,我必须将下面提到的策略添加到我的 IAM 用户来解决这个问题。参考
git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true
Run Code Online (Sandbox Code Playgroud)
政策:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"codecommit:*"
],
"Resource": "*"
}
]
}
Run Code Online (Sandbox Code Playgroud)
可在AWS文档上找到此有用的文本以进行代码提交和Windows集成
如果您的Git for Windows安装中包含Git Credential Manager实用程序,则在前几次尝试连接后,您将看到403错误或提示向Credential Manager实用程序提供凭据。解决此问题的最可靠方法是卸载Git for Windows,然后重新安装,而无需使用Git Credential Manager实用程序,因为它与AWS CodeCommit不兼容。
如果您想保留Git Credential Manager实用程序,则必须执行其他配置步骤以也使用AWS CodeCommit,包括手动修改.gitconfig文件以在连接到AWS CodeCommit时指定使用AWS CodeCommit的凭证帮助程序。
从凭据管理器实用程序中删除所有存储的凭据(您可以在控制面板中找到此实用程序)。
删除所有存储的凭据后,请将以下内容添加到.gitconfig文件中,进行保存,然后尝试从新的命令提示符窗口再次连接:
[credential "https://git-codecommit.us-east-1.amazonaws.com"]
helper = !aws codecommit credential-helper $@
UseHttpPath = true
Run Code Online (Sandbox Code Playgroud)
此外,您可能必须通过指定--system而不是--global或--local来重新配置git config设置,然后所有连接才能正常工作。
这最后一部分适用于我的情况,尽管当我运行git config --system时,它没有按预期运行,但在aws codecommit命令之前附加了aws configure。
因此,我必须在git中运行它才能找到系统配置文件的位置。
git config --list --show-origin
Run Code Online (Sandbox Code Playgroud)
然后,我将来自AWS的建议部分添加到我的c:/users/username/.gitconfig和我的c:/ ProgramData / Git / config文件中。
在该git push开始工作后,即使我在收到以下错误响应之前仍收到虚假错误:
"git: 'credential-aws' is not a git command. See 'git --help'."
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14207 次 |
| 最近记录: |