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


当前回答

视觉指南(Windows)

1 / 2。Git批处理端

1.1. 打开git批处理(下载她)

1.2. 粘贴下面的文本(更改到您的GitHub帐户电子邮件)

$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

1.3. 按Enter(接受默认文件位置)

1.4. 单击Enter两次(或设置SSH密钥passphrases - Gitbub passphrases docs)

> Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]

1.5. 键生成:

您的身份信息已保存在/c/Users/user/.ssh/id_rsa…

1.6. 将SSH密钥复制到剪贴板。

$ clip < ~/.ssh/id_rsa.pub

2 / 2。Github网站用户端

在用户设置下

SSH和GPG密钥=>新的SSH密钥:

粘贴步骤1.6中的代码

:完成)


如果有人不想使用SSH,请使用HTTPS:

Github docs: https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh

其他回答

在我的例子中,这个奇怪的错误是gnome-keyring-daemon错误地命名了需要密码的密钥的症状。

我按照这里列出的步骤,并通过终端输入密码。这个错误,也就是混乱的GUI界面,已经解决了。 参见:https://askubuntu.com/questions/3045/how-to-disable-gnome-keyring

在我的MAC中,我解决了这个问题:

cp ~/.ssh/github_rsa ~/.ssh/id_rsa

出于某种原因,我的git停止在github_rsa文件中寻找私钥。这发生在一次特定的回购中。我的意思是在其他存储库中git保持正常工作。

我想这是个bug。

我可以在运行ssh -vT git@github.com时发现这种行为

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

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

这些是我在windows 10中遵循的步骤

打开Git Bash。 生成公钥: ssh-keygen -t rsa -b 4096 -C "youremailaddress@xyz.com" 复制生成的键到剪贴板(像CTRL+C一样工作) 剪辑< ~/.ssh/id_rsa.pub 浏览器,进入Github => Profile=> Settings => SSH和GPG Key => Add Key 提供键名和粘贴剪贴板(CTRL+V)。 最后,测试您的连接(Git bash) ssh -T git@github.com

谢谢!

当我试图运行一个makefile时,我得到了类似的权限拒绝(publickey)错误。

作为上述SSH步骤的替代方法,您可以安装本地GitHub for Mac应用程序。

点击下载GitHub for Mac从- https://help.github.com/articles/set-up-git#platform-mac

一旦你用你的git hub帐户完成了设置(我也安装了git hub命令行工具,但不确定是否需要这一步),然后我收到了一封电子邮件-

[GitHub]一个新的公钥已添加到您的帐户

我的错误被纠正了。