解决Permission denied (publickey). Could not read from remote repository.,不能生成rsa.pub的问题

[email protected]: Permission denied (publickey). Could not read from remote repository.  Please make sure you have the correct access rights and the repository exists.

 

原因分析

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

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

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

客户端生成ssh key

1、

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

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

 

解决Permission denied (publickey). Could not read from remote repository.,不能生成rsa.pub的问题_第1张图片


然后再终端下执行命令:

ssh -v [email protected]

最后两句会出现

解决Permission denied (publickey). Could not read from remote repository.,不能生成rsa.pub的问题_第2张图片

  No more authentication methods to try.  
  Permission denied (publickey).

在终端再执行以下命令

 

ssh-agent -s 

 

[root@ad~]# ssh-agent -s 
SSH_AUTH_SOCK=/tmp/ssh-3desWIceGSpo/agent.29561; export SSH_AUTH_SOCK;
SSH_AGENT_PID=29562; export SSH_AGENT_PID;
echo Agent pid 29562;

 

接着在执行

 

ssh-add ~/.ssh/id_rsa

如果出现

Could not open a connection to your authentication agent.

请执行下

 ssh-agent bash

如果没有输出表示执行成功!

重新执行

ssh-add ~/.ssh/id_rsa
出现

Identity added: /root/.ssh/id_rsa ([email protected])

说明成功了

一般情况下去 /root/.ssh/

找到 id_rsa.pub结尾的文件,查看下,添加到github的

 

配置服务端

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

解决Permission denied (publickey). Could not read from remote repository.,不能生成rsa.pub的问题_第3张图片

titie 随便写

解决Permission denied (publickey). Could not read from remote repository.,不能生成rsa.pub的问题_第4张图片
webp

 

 

 

 

 

验证Key

 

ssh -T [email protected] 

 

提示:Hi xxx! You've successfully authenticated, but GitHub does not provide shell access. 问题就解决啦

 

你可能感兴趣的:(开发应用,github)