Permission denied(publickey)错误

在使用Git的时候遇到的,在本地执行

git push -u origin master

的时候出现。完整的错误提示是这样的

$ git push -u origin master
Agent admitted failure to sign using the key.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

 第一步:尝试了stackoverflow上的一个解答,它的问题描述和我几乎完全相同,答案如下,但是并未完全解决问题。

 

first start by setting up your own public/private key pair set. This can use either dsa or rsa, so basically any key you setup will work. On most systems you can use ssh-keygen.

  • But first you want to make sure you cd into your .ssh directory. Open up the terminal and run cd ~/.ssh && ssh-keygen
  • next you need to copy this to your clipboard. On OSX run cat id_rsa.pub | pbcopy on Linux runcat id_rsa.pub | xclip
  • next add your key to your account finally setup your git config
    • git config --global user.name "bob"
    • git config --global user.email bob@... (don't forget to restart your command line to make sure the config is reloaded)

Thats it you should be good to clone and checkout.

 但是实际操作完之后还是有问题,错误提示是这样

Agent admitted failure to sign using the key.

我的git之前就是配置过的,可能就一两周之前还成功push过,这次是push一个新的Repo就出问题了。

第二步:采用了另一个博客里的解决方法

ssh-keygen 產生出 id_rsa, id_rsa.pub, 已經都放到正確位置(.ssh), 但是連線時卻出現下述訊息:

Agent admitted failure to sign using the key

 

解法

於自己的機器上, 執行 ssh-add, 會出現下述訊息.

Identity added: /home/user/.ssh/id_rsa (/home/user/.ssh/id_rsa)

再次連線就正常囉~

 根据这个播客的描述,操作就解决问题了。但是根据这个播客的描述,第一步可能也是有必要的只是不完整。

而且这个属于是SSH的问题,并不是Git或者Github的问题,之所以会遇到只是因为Github使用了SSH协议传输文件。

但是现在Github好像也开始支持HTTP协议的传输了,所以也可能换个协议来避免这个问题。

但作为程序员会使用SSH的话,稍微了解一些,还是不错的。

posted on 2013-04-15 16:50  褐鹤  阅读(1334)  评论(0编辑  收藏  举报

导航