【问题标题】:Cannot clone using deploy key (bitbucket) EC2无法使用部署密钥 (bitbucket) EC2 进行克隆
【发布时间】:2015-02-05 17:02:27
【问题描述】:

我无法使用我的部署密钥将我的存储库克隆到我的远程 EC2 ubuntu 实例。 以下是我遵循的步骤。

  1. 我删除了我的 bitbucket 帐户中的现有部署密钥
  2. 我清理了~/.ssh/know_hosts 关注https://stackoverflow.com/a/26520681/808734
  3. 我在these steps 之后生成了我的新密钥 并将其作为deployment key 添加到存储库中。
  4. 这是ssh -T git@bitbucket.org的输出

    You can use git or hg to connect to Bitbucket. Shell access is disabled. This deploy key has read access to the following repositories: username/repository: KEYNAME -- email@gmail.com

  5. 但是当我尝试克隆存储库时
    sudo git clone git@bitbucket.org:username/repository.git 我收到以下错误 Cloning into 'repository'... Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

我在这里遗漏了什么吗?有人有什么建议吗?

感谢阅读。

【问题讨论】:

    标签: git ssh amazon-ec2 bitbucket


    【解决方案1】:

    这很尴尬,这里的问题是我以sudo 用户身份运行命令。

    sudo git clone git@bitbucket.org:username/repository.git 
    

    这可能是试图以 root 用户身份克隆存储库并导致错误。但是,克隆为当前用户,并提供对所需目录的写入权限,让我可以成功克隆存储库。

    在此过程中,我的 ssh 密钥似乎已被重置, 所以请确保ssh -T git@bitbucket.org 按预期工作。如果没有,运行

    # start the ssh-agent in the background
    eval "$(ssh-agent -s)"
    # Agent pid 59566
    ssh-add ~/.ssh/id_rsa
    

    为我工作。 more details

    【讨论】:

    • ssh-add 救了我。即使在我创建了一个新密钥并尝试了那个密钥之后,我也必须使用ssh-add 手动添加它。干得好!
    • 哇!做到了!,如果不是问题,你能告诉真正的问题是什么,这段代码做了什么?
    【解决方案2】:
    fatal: Could not read from remote repository. 
    Please make sure you have the correct access rights and the repository exists.
    

    对于很多 GIT 用户来说似乎是一个反复出现的问题。

    确保使用正确的用户名和网址!

    git: fatal: Could not read from remote repository 可能会有所帮助。

    祝你好运!

    【讨论】:

      【解决方案3】:

      如果您是团队的一员并尝试克隆存储库,那么您可能需要稍微更改 url,即

      来自

      ssh://git@bitbucket.org:team_name/repo_name.git

      ssh://git@bitbucket.org/team_name/repo_name.git

      【讨论】:

        猜你喜欢
        • 2019-10-27
        • 1970-01-01
        • 2017-02-19
        • 2021-09-05
        • 1970-01-01
        • 1970-01-01
        • 2016-11-20
        • 2017-06-02
        • 2015-07-27
        相关资源
        最近更新 更多