Permission denied (publickey). fatal: Could not read from remote repository.

When the blogger downloaded the source code of tiny face on github, he encountered the git clone command: git clone --recursive [email protected]:peiyunh/tiny.git

  And when I execute this statement under ternimal, I get an error:

  Permissiondenied (publickey).

  fatal:Could not read from remote repository.

  Pleasemake sure you have the correct access rights

  and the repository exists.

  But in fact, executing the command: git clone [email protected]:peiyunh/tiny.git is no problem (without the --recursive parameter), so Baidu did some research. I understand that the reason is that you are in the local (or server) above) without generating the ssh key, you can execute under ternimal:

  cd ~/.ssh ls to see if there is the file id_rsa and the file id_rsa.pub, as shown in the following figure: (mine has been generated, so it will be displayed after I ls.)

  

  Record the solution below:

  1. First, if you don't have a ssh key, enter the command under ternimal: ssh-keygen -t rsa -C "[email protected]", [email protected] can be changed to your own mailbox, and you will be asked on the way. Enter the password or something, you don't need to worry, just press Enter all the way, and your ssh key will be generated. (If you regenerate it, it will overwrite the previous ssh key.)

  

  2. Then execute the command under ternimal:

  ssh -v [email protected] 

  The last two sentences will appear:

  No more authentication methods to try.  

  Permission denied (publickey).

  3.这时候再在ternimal下输入:

  ssh-agent -s

  然后会提示类似的信息:

  SSH_AUTH_SOCK=/tmp/ssh-GTpABX1a05qH/agent.404; export SSH_AUTH_SOCK;  

  SSH_AGENT_PID=13144; export SSH_AGENT_PID;  

  echo Agent pid 13144;

  4.接着再输入:

  ssh-add ~/.ssh/id_rsa

  这时候应该会提示:

  Identity added: ...(这里是一些ssh key文件路径的信息)

  (注意)如果出现错误提示:

  Could not open a connection to your authentication agent.

  请执行命令:eval `ssh-agent -s`后继续执行命令 ssh-add ~/.ssh/id_rsa,这时候一般没问题啦。

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

  6.最后一步,验证Key

  在ternimal下输入命令:

  ssh -T [email protected]

  提示:Hi xxx! You've successfully authenticated, but GitHub does not provide shell  access.

  这时候你的问题就解决啦,可以使用命令 git clone --recursive [email protected]:peiyunh/tiny.git 去下载你的代码啦。

转载地址:https://www.cnblogs.com/wmr95/p/7852832.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324737578&siteId=291194637