Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

实测有效。

原文地址:https://www.jianshu.com/p/3b56f4e6ac77

之前使用git进行push或者clone操作的时候出现如下错误:

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,所以无法识别。 因而需要获取本地电脑公钥,然后登录github账号,添加公钥至github就OK了。

设置Git的user name和email

git config --global user.name "yourname" git config --global user.email "youremail" 

生成SSH密钥

查看是否已经有了ssh密钥:cd ~/.ssh
如果没有密钥则不会有此文件夹,有则备份删除
生存密钥:
ssh-keygen -t rsa -C “youremail”
按3个回车,密码为空。
Your identification has been saved in /home/tekkub/.ssh/id_rsa.Your public key has been saved in /home/tekkub/.ssh/id_rsa.pub.The key fingerprint is:
………………
最后得到了两个文件:id_rsa和id_rsa.pub

在github上添加ssh密钥,这要添加的是“id_rsa.pub”里面的公钥。打开github在设置中添加密钥

按照指令操作会进入vim编辑模式,上边的序列码即为公钥,复制序列码,包含(ssh-rsa等标识)。不同操作系统和电脑可能公钥路径不一样,以实际情况为准.
登录github后,进入个人设置settings—>ssh and gpg keys–>new ssh key 添加即可。title自行命名

add ssh key成功后,github就可以识别你的机器,允许你从github拉取代码了。

作者:Smallwolf_JS
链接:https://www.jianshu.com/p/3b56f4e6ac77
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

发表评论

电子邮件地址不会被公开。 必填项已用*标注