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_rsa
和id_rsa.pub
添加秘钥
在github上添加ssh**,这要添加的是id_rsa.pub
里面的公钥
在github官网,点击头像->Settings->SSH and GPG keys->New SSH key,添加公钥即可
添加公钥之后,就可以从github正常拉取代码了