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


当前回答

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

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

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

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

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

我的错误被纠正了。

其他回答

总是检查github ssh密钥生成程序,而不是一些过时的博客

https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

在这里你可以看到键是通过以下方式生成的:

ssh-keygen -t ed25519 -C "your_email@example.com"

所以算法是ed25519而不是rsa或者别的什么。

对我来说,问题是使用sudo:

sudo git克隆git@github.com:userName/repo.git导致上述错误。

所以为了解决这个问题,我咀嚼了我试图克隆到的文件夹

sudo chown -R $USER:$USER /var/www/iqge.org/html

然后用这个 git克隆git@github.com:userName/repo.git was successfully done

更广泛的故障排除,甚至自动修复可以完成:

ssh -vT git@github.com

或者,根据以下意见,我们可以发出:

ssh -vT git@gitlab.com

或者用你的组织正在运行的Git实例替换gitlab/github。

来源:https://help.github.com/articles/error-permission-denied-publickey/

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

我今天在尝试使用git bash在windows中设置一个现有的存储库时遇到了这个问题。问题出现在输入以下内容时:

git clone myreposshurl

在gitbash中,ctrl+c和ctrl+v不起作用。在尝试粘贴存储库url时,我按了ctrl+v,这引入了一些不需要的字符。当我尝试并成功克隆另一个存储库时,终于发现并解决了这个问题。花了一个半小时才发现这个愚蠢的错误。

\302\226git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

如果你看到像上面这样的\302字符,那么这可能是一个可能的原因。