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

今天clone一份github代码,报错:Could not read from remote repository

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-keygen -t rsa -C "youremail"

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

添加秘钥

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

© 版权声明
THE END
喜欢就支持一下吧
点赞0赞赏 分享
评论 抢沙发

请登录后发表评论

    请登录后查看评论内容