在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时出现错误?
答案 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
目录搜索您的私有密钥。