欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

git clone报错:Permission denied (publickey). fatal: Could not read from remote repository...

程序员文章站 2022-07-13 16:11:41
...

原文:git clone报错:Permission denied (publickey). fatal: Could not read from remote repository…

今天clone一份github代码,报错:

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

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

查了资料发现是因为本机的publickey没有添加到github(因为刚刚重装了系统),之前一直以为访问公开库没有添加公钥的要求,这波才知道原来只要是clone github代码就需要添加公钥

秘钥生成

ssh-****** -t rsa -C "youremail"

密码不用设置,直接回车即可。完成后在 ~/.ssh 目录生成两个文件:id_rsaid_rsa.pub

添加秘钥

在github上添加ssh**,这要添加的是id_rsa.pub里面的公钥
在github官网,点击头像->Settings->SSH and GPG keys->New SSH key,添加公钥即可
git clone报错:Permission denied (publickey). fatal: Could not read from remote repository...
添加公钥之后,就可以从github正常拉取代码了

相关标签: 工具 # git