SSH检查成功,但仍无法克隆git repo

时间:2018-07-16 08:38:28

标签: git ssh

在Mac中,我已经在~/.ssh目录中生成了ssh密钥。

,我还将id_rsa.pub的公钥复制到了我的GitHub帐户设置SSH密钥中。

但是我无法从GitHub克隆,

$ sudo git clone git@github.com:WHMCS/templates-six.git whmcs_six_template
Cloning into 'whmcs_six_template'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

然后我搜索了google,找到了一种检查SSH连接的方法:

$ ssh -T git@github.com
Hi sof-3! You've successfully authenticated, but GitHub does not provide shell access. 

您看到此检查成功,为什么克隆git repo时出现错误?

1 个答案:

答案 0 :(得分:1)

您应将当前帐户用于git clone:

$ git clone git@github.com:WHMCS/templates-six.git whmcs_six_template

因为此id_rsa.pub在您当前的用户~/.ssh/id_rsa.pub下,所以如果您使用root用户进行克隆,它将使用root用户的.ssh目录搜索您的私有密钥。