Git公钥出现问题解决办法

318 阅读1分钟

问题:

Please make sure you have the correct access rights and the repository exists
请确保您具有正确的访问权限并且存储库存在

原因:

公钥出问题了,需要删除.ssh下文件,然后重设置用户名和邮箱再重新生成ssh公钥即可解决

解决:

步骤一:删除.ssh下所有所有文件

20200812230450785.png 步骤二:

1.设置用户名
git config --global user.name ‘zhandehuang’
2.设置用户名邮箱
git config --global user.email ‘it_zdh@163.com’
3.查看设置
git config --list

20200812231212512.png 然后继续输入命令:修改后面的邮箱即可

ssh-keygen -t rsa -C "it_zdh@163.com"

20200812231533338.png

  • 配置:github

20200812211848812.png

  • 配置SSH

20200812212021985.png

  • 完成

20200812212258267.png

然后再重新去试试提交,可以正常推送,但会报一个提示

The authenticity of host 'github.com (20.205.243.166)' can't be established.
ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
Are you sure you want to continue connecting (yes/no/[fingerprint])? 

这是因为刚新生成了秘钥少了一个known_hosts文件,本来密钥文件应该是三个,现在是两个,就会报这样的错误,此时选择yes回车之后,即可,同时生成缺少的known_hosts文件

Are you sure you want to continue connecting (yes/no)? //输入yes,回车