Git远程克隆仓库出现Permission denied (publickey)

$ git clone git@github.com:DavidWanderer/test1.git
Cloning into 'test1'...
Warning: Permanently added the RSA host key for IP address '192.30.253.113' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

MAC终端克隆仓库出现以上错误。原因是没有将自己电脑的SSH key添加到GitHub上。解决办法:

1.生成SSH Key

$ ssh-keygen -t rsa -C "XXXX.com"

2.找到生成Key值的目录,前往.ssh目录,这个目录下会生成三个文件:id_rsa(私钥),id_rsa.pub(公钥),known_hosts。

《Git远程克隆仓库出现Permission denied (publickey)》

3.登录GitHub,然后选择Personal Settings->SSH and GPG keys->New SSH Key

title随便填一个,然后把第二步产生的id_rsa.pub中的文本内容复制到key的文本框中,然后点击Add SSH key,然后在MAC终端重新克隆,就可以正常克隆了。

《Git远程克隆仓库出现Permission denied (publickey)》

 

参考链接:

远程仓库

 

 

 

点赞