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

  • 解决[email protected]: Permission denied (publickey). fatal: Could not read from remote repository.已关闭评论
  • 279 次浏览
  • A+
所属分类:Web前端
摘要

今天想要把项目git到github上,结果最后一步git push的时候报错如下:然后就可以继续再git上push你的项目了

push成功我的第一个github项目啦!✌

今天想要把项目git到github上,结果最后一步git push的时候报错如下:

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

  1. 原因
    Permission denied (publickey) 没有权限的publickey ,
    出现这错误一般是以下两种原因:
    客户端与服务端未生成 ssh key
    客户端与服务端的ssh key不匹配
    找到问题的原因了,解决办法也就有了,重新生成一次ssh key 即可。
  2. 解决
  • 首先win+R输入cmd打开命令行
  • 然后输入命令:
    ssh-keygen -t rsa -C "[email protected]"
    "[email protected]"改为自己的邮箱即可,途中会让你输入密码啥的,不用管,一路回车即可,会生成你的ssh key。(如果重新生成的话会覆盖之前的ssh key。)
    解决git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
  • 然后按照路径目录打开id_rsa.pub文件
    解决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.
  • 在github上打开箭头处,点击Settings
    解决git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
  • 点击SSH and GPG keys,然后点击Add SSH Key
    解决git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
  • 把刚刚复制的id_rsa.pub文件里面的内容粘贴进去
    解决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.

然后就可以继续再git上push你的项目了
解决git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
push成功我的第一个github项目啦!✌