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


当前回答

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

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

其他回答

伙计们我是这么干的

Open terminal and go to user [See attached image] Open .ssh folder and make sure it doesn't have any file like id_rsa or id_rsa.pub otherwise sometimes it wont properly rewrite files git --version [Check for git installation and version] git config --global user.email "your email id" git config --global user.name "your name" git config --list [make sure you have set your name & email] cd ~/.ssh ssh-keygen, it prompts for saving file, allow it cat ~/.ssh/id_rsa.pub [Access your public key & copy the key to gerrit settings]

注意:你不应该在Git中使用sudo命令。如果您有非常好的理由必须使用sudo,那么请确保您在每个命令中都使用它(此时使用su作为根来获取shell可能更好)。如果您不使用sudo生成SSH密钥,然后尝试使用sudo git push之类的命令,那么您将不会使用您生成的相同密钥

我得到了同样的错误。我的问题是混入sudo。

如果不给git clone命令加上sudo前缀,就无法自动创建要克隆到的目录。然而,当我这样做的时候,我的ssh键没有被正确引用。

为了解决这个问题,我通过chmod在我想要包含我的克隆的父目录上设置权限,这样我就可以对它进行写入。然后我运行git克隆没有一个sudo前缀。然后它成功了!之后我把权限改回来了。完成了。

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

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

sudo cp ~/.ssh/* /root/.ssh/
$ cd ~
$ cd .ssh
$ chmod 400 id_rsa