从BitBucket推送到CodeCommmit时出错

时间:2018-04-14 11:26:38

标签: git bitbucket bitbucket-pipelines aws-codecommit

我已经设置了一个Bitbucket管道,按照https://medium.com/@jay_proulx/aws-codecommit-from-atlassian-bitbucket-and-bitbucket-pipelines-for-ci-offloading-4f1131695802

的Jay Proulx的说明推送到CodeCommit

我已将一个ssh密钥(由W​​indows上的puttygen生成)上传到AWS IAM,并在Bitbucket Pipeline变量中进行了如下配置。

bitbucket-pipelines.yml看起来像:

pipelines:
  default:
    - step:
        script:
          - echo $CodeCommitKey > ~/.ssh/codecommit_rsa.tmp
          - base64 -d ~/.ssh/codecommit_rsa.tmp > ~/.ssh/codecommit_rsa
          - chmod 400 ~/.ssh/codecommit_rsa
          - echo $CodeCommitConfig > ~/.ssh/config.tmp
          - base64 -d  ~/.ssh/config.tmp > ~/.ssh/config
          - set +e
          - ssh -o StrictHostKeyChecking=no $CodeCommitHost
          - set -e
          - git remote add codecommit ssh://$CodeCommitRepo
          - git push codecommit $BITBUCKET_BRANCH

$ CodeCommitConfig是base64编码版本:

   Host git-codecommit.ap-southeast-2.amazonaws.com
        HostName git-codecommit.ap-southeast-2.amazonaws.com
        User APKAxxxx
        IdentityFile ~/.ssh/codecommit_rsa

Bitbucket管道中的环境变量:

$CodeCommitHost = git-codecommit.ap-southeast-2.amazonaws.com
$CodeCommitRepo = git-codecommit.ap-southeast-2.amazonaws.com/v1/repos/myrepo
$CodeCommitUser = APKAxxxx
$CodeCommitKey = [The base64 encoded version of the SSH private key]

在管道的最后一步,我收到错误:

+ git push codecommit $BITBUCKET_BRANCH
ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

我在之前的步骤中遇到了类似的错误:

+ ssh -o StrictHostKeyChecking=no $CodeCommitHost
Pseudo-terminal will not be allocated because stdin is not a terminal.
Warning: Permanently added the RSA host key for IP address '103.8.175.33' to the list of known hosts.
ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory
Permission denied (publickey).

我已经完成了几次设置并得到了相同的结果 - 我做错了什么?

1 个答案:

答案 0 :(得分:0)

不要使用puttygen生成密钥,而是使用git bash中的ssh-keygen。