我用的是Mac雪豹,刚刚安装了git。

我只是试了

git clone git@thechaw.com:cakebook.git

但这给了我这个错误:

Initialized empty Git repository in `/Users/username/Documents/cakebook/.git/`
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

我错过了什么? 我也试过做ssh-keygen没有密码,但仍然错误。


当前回答

SourceTree for Windows case

如果你在Windows上使用SourceTree,你需要使用PuTTyGen创建一个新的keypair

您应该插入到的顶部部分的ssh-rsa密钥

Github => Profile=> Settings => SSH and GPG keys => Add Key

然后保存私钥并将其添加到Pageant(它与SourceTree一起运行)

这是所有

其他回答

SourceTree for Windows case

如果你在Windows上使用SourceTree,你需要使用PuTTyGen创建一个新的keypair

您应该插入到的顶部部分的ssh-rsa密钥

Github => Profile=> Settings => SSH and GPG keys => Add Key

然后保存私钥并将其添加到Pageant(它与SourceTree一起运行)

这是所有

请注意(至少对于某些项目),您必须拥有一个带有ssh密钥的github帐户。

查看身份验证代理中列出的密钥(ssh-add -l) (如果你没有看到任何,用ssh-add /path/到/your/key添加一个你现有的密钥(例如:ssh-add ~/.ssh/id_rsa)) (如果你没有任何密钥,首先创建一个。参见:http://rcsg-gsir.imsb-dsgi.nrc-cnrc.gc.ca/documents/internet/node31.html或谷歌ssh-keygen)

要验证您有一个与您的github帐户相关联的密钥:

访问:https://github.com/settings/ssh

您应该至少看到一个键的哈希键与您刚才键入ssh-add -l时看到的某个哈希键相匹配。

如果没有,添加一个,然后再试一次。

我有一个轻微不同的情况,我登录到一个远程服务器,并在服务器上使用git,当我运行任何git命令时,我得到了相同的消息

   Permission denied (publickey).
   fatal: The remote end hung up unexpectedly

我是通过修改Mac上的/etc/ssh_config文件来解决这个问题的。 从

ForwardAgent no 

to

ForwardAgent yes

当你试图用不同的用户名推送到存储库时,最简单的解决方案是:

 git remote set-url origin https://USERNAME@github.com/USERNAME/PROJECTNAME.git

在我的ubuntu系统中,我按照下面的步骤解决了这个问题。因为我正在尝试用无密码ssh到系统。

sudo vi /etc/ssh/sshd_config

1)评论如下: #更改为no禁用隧道明文密码 # PasswordAuthentication是的 PasswordAuthentication no ---->注释此。

2)然后重新启动sshd守护进程,如下所示。

重启SSHD服务