我用的是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没有密码,但仍然错误。


当前回答

我帮助了以下方面:

打开终端(Git Bash) 删除.ssh目录下的所有文件或重命名并创建新的.ssh文件夹。 按照说明的步骤操作: 生成新的SSH密钥 将SSH密钥添加到SSH -agent

系统:Windows 10。

其他回答

这对我很有效

ssh -i [your id_rsa path] -T github@github.com

使用来自Github的ssh链接,但确保不要附加ssh,只需使用git hub上的ssh选项卡来克隆你的repo。

github帮助链接帮助我解决了这个问题。看起来ssh密钥没有添加到ssh-agent。这就是我最后做的事。

命令1:

确保ssh-agent已启用。在后台启动ssh-agent:

eval "$(ssh-agent -s)"

命令2:

将SSH密钥添加到SSH -agent:

ssh-add ~/.ssh/id_rsa

SourceTree for Windows case

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

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

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

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

这是所有

在Windows上,确保所有应用程序的HOME一致。令人惊讶的是,Msys不会为你做这件事。我不得不设置一个环境变量,因为ssh和git似乎无法就我的.ssh目录在哪里达成一致。