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

今天用idea提交代码到github上,push后报错

[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.

解决git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Pleas_第1张图片

 

一:原因分析

Permission denied (publickey) 没有权限的publickey ,出现这错误一般是以下两种原因

  • 客户端与服务端未生成 ssh key
  • 客户端与服务端的ssh key不匹配

找到问题的原因了,解决办法也就有了,重新生成一次ssh key ,服务端也重新配置一次即可。

 

二:客户端生成ssh key

在cmd里面输入

ssh-keygen -t rsa -C "[email protected]"

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. Pleas_第2张图片

 

三:输入箭头处路径

解决git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Pleas_第3张图片

 

四:打开id_rsa.pub文件,并且复制内容

解决git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Pleas_第4张图片

 

 

配置服务端

五:在github上打开箭头处,点击Setting

解决git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Pleas_第5张图片

 

 

六:点击SSH and GPG keys

 

解决git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Pleas_第6张图片

 

七:打开你刚刚生成的id_rsa.pub,将里面的内容复制,进入你的github账号,在settings下,SSH and GPG keys下new SSH key,然后将id_rsa.pub里的内容复制到Key中,完成后Add SSH Key。

解决git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Pleas_第7张图片

 

八:然后添加后入下图所示

解决git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Pleas_第8张图片

 

 

九:用idea再次提交文件到 github上,显示提交成功

解决git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Pleas_第9张图片

你可能感兴趣的:(Git)