无法使用SSH

时间:2016-01-03 19:26:36

标签: git ssh aws-codecommit

非常难以确定如何使AWS CodeCommit与标准SSH身份验证协同工作。看到像这样的另一个话题,但没有答案,我还不能发表评论。这是在Windows上使用Git Bash。

Repro Steps

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

    为了比较,这是我使用与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).
    

    以上输出来自git push origin master中启用了ssh调试日志的.ssh/config正常git命令:

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

6 个答案:

答案 0 :(得分:8)

看起来你错过了设置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

您可以从IAM控制台获取您的SSH-Key-ID。

答案 1 :(得分:1)

enter image description here这有效

To Set:
localStorage.setItem("flightdetails", dataStorage );

To get:
var flightdetails = localStorage.getItem("flightdetails");

答案 2 :(得分:1)

请遵循 AWS 中的以下文档

Linux

https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-ssh-unixes.html

Windows

https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-ssh-windows.html

我已经测试过只为 Windows 设置 SSH 连接,请按照上面提到的链接测试 Linux 的 SSH 连接;

以下是在 Windows 10 上为 codecommit 设置 SSH 连接的步骤。

第一步

CodeCommit 的初始配置(请参考文档链接)

第 2 步

安装 Git(请参考文档链接)

步骤 3

通过运行以下命令生成 ssh 密钥:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

运行此命令后,它应该在 C:\Users{user name here}.ssh 目录中生成公钥(.pub)和私钥

步骤 4

登录 aws 管理控制台并转到 IAM--> 用户 --> 选择目标用户 --> 安全凭证选项卡 --> AWS CodeCommit 的 SSH 密钥 然后单击上传 ssh 密钥。复制粘贴公钥的内容,例如 C:\Users{user name here}.ssh\id_rsa.pub 并保存更改。但是您可以在使用命令时为您的公钥(id_rsa.pub)选择不同的名称 {{1 }}

第 5 步:

上传公钥后,复制SSH密钥ID。

步骤 6

创建 C:\Users{user name here}.ssh\config 文件(没有文件扩展名,在 Windows 中将其另存为 config 并选择所有文件类型选项。Config.txt 很可能不起作用)。 将以下内容粘贴到 C:\Users{user name here}.ssh\config 文件中:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com".

步骤 7

Host git-codecommit.*.amazonaws.com
  User {copy SSH key ID here}
  IdentityFile ~/.ssh/{copy name of the public key here }
  
Host git-codecommit.*.amazonaws.com
  User THISISEXMAPLE123
  IdentityFile ~/.ssh/id_rsa
  

答案 3 :(得分:0)

我的情况有点不同。

“安全凭证”选项卡同时具有“访问密钥”和“ AWS CodeCommit的SSH密钥”。确保您使用的是CodeCommit密钥ID。

答案 4 :(得分:0)

确保未将配置文件另存为txt文件,并使用SSH密钥ID,而不是Access

答案 5 :(得分:0)

在制作 git clone 时尽量使用 sshkey-ID enter image description here

所以 git clone 应该是这样的:

git clone ssh://<SSHKEY-ID>@git-codecommit.<REGION>.amazonaws.com/v1/repos/<REPO-NAME>
相关问题