克隆git存储库权限被拒绝

时间:2014-03-28 08:22:12

标签: git bitbucket

我的bitbucket帐户上有一个私人存储库。今天我想要 添加一台新计算机以访问其中一个私有存储库。

所以我做了以下事情:

ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/d/.ssh/id_rsa): 
Created directory '/d/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /d/.ssh/id_rsa.
Your public key has been saved in /d/.ssh/id_rsa.pub.

之后我从id_rsa.pub复制了密钥并将其添加到我的列表中 我的bitbucket存储库上的ssh-keys。

然而......当我现在要克隆我的存储库时,我收到以下错误:

Permssion denied (publickey)
fatal: Could not read from remote repository

问题出在哪里?

1 个答案:

答案 0 :(得分:0)

从BitBucket克隆时,请确保使用生成的私钥(在您的情况下为id_rsa):

git -i /path/to/your/private/key clone git@bitbucket.org/owner/project.git


修改
更永久和方便的解决方案是省略上述命令中的-i /path/to/your/private/key部分,而是在SSH配置文件中包含以下内容:

Host bitbucket.org
  IdentityFile /path/to/your/private/key