我用的是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


对我来说,我一直在得到

git@github.com: Permission denied 
fatal: Could not read from remote 

Please make sure you have the correct access rights
and the repository exists.

所以经过几个小时的研究,我发现在生成您的ssh密钥并使您的windows代理识别您的密钥后,我做的最后一件事来解决我的问题是更新ssh密钥在git回购的项目。

你可以登录到你的git hub账户,然后进入你想要推送的repo,然后在设置中寻找安全性,在那里你可以添加ssh密钥。对于我来说,密钥存储在.ssh/id_ed123939.pub中

其他回答

我已经使用gh进行了身份验证,创建了新的密钥,等等。问题是我在Ubuntu中安装了带snap的gh,所以生成的新密钥在。/snap/gh/502/。Ssh /,而不是常规的. Ssh路径。

我解决了它复制一切到。ssh文件夹:

cp -a ./snap/gh/502/.ssh/* .ssh/

如果没有,用find找到你的钥匙。- name * .pub

我想,在数字世界里,知道你把钥匙放在哪里仍然是个问题。

总是检查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或者别的什么。

我必须将ssh密钥复制到根文件夹。 谷歌云计算引擎,Ubuntu 18.04

sudo cp ~/.ssh/* /root/.ssh/

我今天在尝试使用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字符,那么这可能是一个可能的原因。

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

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