[email protected]: Permission denied (publickey). fatal: Could not read from remote repository的问题解决

[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

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

大概率是秘钥设置不对的问题。

1.检查有没有在GitHub的https://github.com/settings/keys上添加你本机的SSH key。注意换了电脑是要重新添加的,每台都不一样。添加SSH key的方法:(引自廖雪峰老师的教程)
在用户主目录下,看看有没有.ssh目录,如果有,再看看这个目录下有没有id_rsa和id_rsa.pub这两个文件,如果已经有了,可直接跳到下一步。如果没有,打开Shell(Windows下打开GitBash),创建SSH Key:

$ ssh-keygen -t rsa -C "[email protected]"
你需要把邮件地址换成你自己的邮件地址,然后一路回车,使用默认值即可。

如果一切顺利的话,可以在用户主目录里找到.ssh目录,里面有id_rsa和id_rsa.pub两个文件,这两个就是SSH Key的秘钥对,id_rsa是私钥,不能泄露出去,id_rsa.pub是公钥,可以放心地告诉任何人。

2.登陆GitHub,打开“Account settings”,“SSH Keys”页面:

然后,点“Add SSH Key”,填上任意Title,在Key文本框里粘贴id_rsa.pub文件的内容:点“Add Key”,你就应该看到已经添加的Key

猜你喜欢

转载自blog.csdn.net/weixin_51583081/article/details/126264799
今日推荐