git@github.com: Permission denied (publickey). fatal: Could not read from remote repository的问题解决

问题描述:git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Failed during: git fetch origin master:refs/remotes/origin/master --tags --force
问题分析:
由于你的github SSH秘钥设置不对导致的。
解决方法

  1. 在你的项目根目录下,右键git bash here
  2. 根据你的邮箱生成公钥和私钥
    命令:ssh-keygen -t rsa -C xxx@163.com
    然后一路回车,使用默认命令即可d在这里插入图片描述
    如上图代表生成成功!如果一切顺利的话,可以在用户主目录里找到.ssh目录,里面有id_rsa和id_rsa.pub两个文件,这两个就是SSH Key的秘钥对,id_rsa是私钥,不能泄露出去,id_rsa.pub是公钥,可以放心地告诉任何人。

在这里插入图片描述上图就是生成的公钥、密钥

  1. 登陆GitHub,打开“Account settings”,“SSH Keys”页面:
    然后,点“Add SSH Key”,填上任意Title,在Key文本框里粘贴id_rsa.pub文件的内容:在这里插入图片描述
    在这里插入图片描述

点击在这里插入图片描述就可以看到生成的密钥了。再次回到项目push你的代码就可以了,大功告成!!

  • 4
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值