无法使用SSH访问AWS CodeCommit

Dan*_*Dan 5 git ssh aws-codecommit

在确定如何使AWS CodeCommit与标准SSH身份验证协同工作时遇到极其困难的时间.看到这样的另一个话题,但没有答案,我不能发表评论.这是在Windows上使用Git Bash.

Repro步骤

  1. 创建具有完全权限的IAM用户(AwsAdministrator)
  2. 来自〜/ .ssh的Git Bash
  3. "cat id_rsa.pub"并将输出复制到剪贴板
  4. 在IAM控制台中,单击按钮添加SSH密钥并粘贴到输入字段中.单击保存.
  5. 尝试访问CodeCommit仓库(在这种情况下尝试推送)并获得"权限被拒绝".

Git + SSH输出

这是我从SSH获得的DEBUG3日志记录:

debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /c/Users/Dan/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 535
debug2: input_userauth_pk_ok: fp SHA256:<omitted>
debug3: sign_and_send_pubkey: RSA SHA256:<same-as-above>
debug1: Authentications that can continue: publickey
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).
fatal: Could not read from remote repository.
Run Code Online (Sandbox Code Playgroud)

为了比较,这是我使用与GitHub完全相同的SSH密钥:

debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /c/Users/Dan/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 535
debug2: input_userauth_pk_ok: fp SHA256:<same-as-above>
debug3: sign_and_send_pubkey: RSA SHA256:<same-as-above>
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([192.30.252.130]:22).
Run Code Online (Sandbox Code Playgroud)

以上输出来自运行正常的git命令,例如git push origin master启用了ssh debug logging .ssh/config:

Host git-codecommit.us-east-1.amazonaws.com
  LogLevel DEBUG3

Host github.com
  LogLevel DEBUG3
Run Code Online (Sandbox Code Playgroud)

Wad*_*nko 10

看起来你错过了设置SSH的一步.您需要将此信息添加到.ssh/config文件中:

Host git-codecommit.us-east-1.amazonaws.com
   User Your-SSH-Key-ID, such as APKAEIBAERJR2EXAMPLE
   IdentityFile Your-Private-Key-File, such as ~/.ssh/codecommit_rsa or ~/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)

您可以从IAM控制台获取Your-SSH-Key-ID.

  • 确实是这个问题,谢谢!如果我查看了 [此处的 Linux/Mac 步骤](http://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-ssh-unixes.html) 而不是尝试翻译 [此处的 Windows 步骤](http://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-ssh-windows.html) (2认同)

小智 8

制作时尝试使用sshkey-IDgit clone 在此输入图像描述

所以 git clone 应该是这样的:

git clone ssh://<SSHKEY-ID>@git-codecommit.<REGION>.amazonaws.com/v1/repos/<REPO-NAME>
Run Code Online (Sandbox Code Playgroud)


aex*_*exl 7

我的情况有点不同。

“安全凭证”选项卡同时包含“访问密钥”和“AWS CodeCommit 的 SSH 密钥”。确保您使用的是 CodeCommit 密钥 ID。 在此输入图像描述


小智 5

在此输入图像描述这有效

Host git-codecommit.us-west-2.amazonaws.com
    User SSHKEYID
    IdentityFile ~/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)