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

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.

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

 

一:原因分析

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

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

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

二:客户端生成ssh key

在cmd里面输入

ssh-keygen -t rsa -C "xxxxxxxx@qq.com"

ssh-keygen -t rsa -C "youremail@example.com"

xxxxxx​​@qq.com​​改为自己的邮箱即可,途中会让你输入密码啥的,不需要管,一路回车即可,会生成你的ssh key。(如果重新生成的话会覆盖之前的ssh key。)

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

 

三:输入箭头处路径

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

 

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

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

 

 

配置服务端

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

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

 

 

六:点击SSH and GPG keys

 

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

 

七:打开你刚刚生成的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_github_07

 

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

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

 

 

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

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