解决git clone提示Permission denied publickey 问题

来源:互联网 发布:java工厂方法设计模式 编辑:程序博客网 时间:2024/06/04 18:36


http://bbs.gsmcn.cn/thread-2474-1-1.html 


偶然编译中文recovery时候遇到了一个错误.后来尝试了一下.解决了,在这里记录分享一下


root@htcdev-VirtualBox:~/Rec_folder# git clone git@github.com:APAR1992/CWM_Recovery_v6037_cn.git
Cloning into 'CWM_Recovery_v6037_cn'...
The authenticity of host 'github.com (192.30.252.131)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.252.131' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
root@htcdev-VirtualBox:~/Rec_folder# 

报错看来是跟publickey有关系
首先来github的解决中心来看 跟着教程走
https://help.github.com/articles/generating-ssh-keys

  1. root@htcdev-VirtualBox:~# cd ~/.ssh
  2. root@htcdev-VirtualBox:~/.ssh# ls
  3. known_hosts
  4. root@htcdev-VirtualBox:~/.ssh# ssh-keygen -t rsa -C recovery@gsmcn.cn  
  5. Generating public/private rsa key pair.
  6. Enter file in which to save the key (/root/.ssh/id_rsa): 
  7. Enter passphrase (empty for no passphrase): 
  8. Enter same passphrase again: 
  9. Your identification has been saved in /root/.ssh/id_rsa.
  10. Your public key has been saved in /root/.ssh/id_rsa.pub.
  11. The key fingerprint is:
  12. 0b:3a:6d:6e:63:e5:6c:a1:1e:1d:c0:61:73:60:5d:d9 recovery@gsmcn.cn
  13. The key's randomart image is:
  14. +--[ RSA 2048]----+
  15. |      *o...o     |
  16. |     + +. . E    |
  17. |      o          |
  18. |       .         |
  19. |      . S        |
  20. |     o ooo       |
  21. |    o +=o.       |
  22. |     +=.+        |
  23. |     +oo         |
  24. +-----------------+
  25. root@htcdev-VirtualBox:~/.ssh# 
复制代码
这里ssh-keygen -t rsa -C "Your@Your.com" 替换为你的邮箱地址,别的都为空,直接回车,就会提示你生成完毕



紧接着执行
  1. ssh-add id_rsa
复制代码
然后系统会提示你
  1. root@htcdev-VirtualBox:~/.ssh# ssh-add id_rsa
  2. Identity added: id_rsa (id_rsa)
复制代码




然后我们去github保存你的ssh key
登录github.com --AccountSetting--ssh  点击Add
然后输入我们刚才计算的key

这里有个简单的复制方法 打开终端 输入
  1. sudo apt-get install xclip
复制代码

然后执行
  1. xclip -sel clip < ~/.ssh/id_rsa.pub
复制代码

直接在key那里右键粘贴 Title随意写。。。



到这里 我们的ssh key 就算添加完毕了
现在去同步下代码看看,终于可以同步了!~




测试环境 ubuntu12.04 

0 0
原创粉丝点击