博主在github上下载tiny face的的源代码的时候,遇到git clone命令为:git clone --recursive git@github.com:peiyunh/tiny.git

  而当我在ternimal下执行这条语句的时候,呈现谬误:

  Permissiondenied (publickey).

  fatal:Could not read from remote repository.

  Pleasemake sure you have the correct access rights

  and the repository exists.

  然而其实执行命令:git clone git@github.com:peiyunh/tiny.git 是没有问题的(不加--recursive参数),于是百度了一番,我了解的是起因是因为你在本地(或者服务器上)没有生成ssh key,你能够在ternimal下执行:

  cd ~/.ssh ls来查看是否有文件id_rsa以及文件id_rsa.pub,如下图所示:(我的曾经生成了,所以我ls后会显示。)

  

  上面记录下解决办法:

  1.首先,如果你没有ssh key的话,在ternimal下输出命令:ssh-keygen -t rsa -C "youremail@example.com", youremail@example.com改为本人的邮箱即可,途中会让你输出明码啥的,不须要管,一路回车即可,会生成你的ssh key。(如果从新生成的话会笼罩之前的ssh key。)

  

  2.而后再ternimal下执行命令:

  ssh -v git@github.com

  最初两句会呈现:

  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 git@github.com

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

  这时候你的问题就解决啦,能够应用命令 git clone --recursive git@github.com:peiyunh/tiny.git 去下载你的代码啦