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


当前回答

对我来说,问题是使用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密钥的github帐户。

查看身份验证代理中列出的密钥(ssh-add -l) (如果你没有看到任何,用ssh-add /path/到/your/key添加一个你现有的密钥(例如:ssh-add ~/.ssh/id_rsa)) (如果你没有任何密钥,首先创建一个。参见:http://rcsg-gsir.imsb-dsgi.nrc-cnrc.gc.ca/documents/internet/node31.html或谷歌ssh-keygen)

要验证您有一个与您的github帐户相关联的密钥:

访问:https://github.com/settings/ssh

您应该至少看到一个键的哈希键与您刚才键入ssh-add -l时看到的某个哈希键相匹配。

如果没有,添加一个,然后再试一次。

伙计们我是这么干的

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之类的命令,那么您将不会使用您生成的相同密钥

最简单的方法之一

〇前往终点站

  git push <Git Remote path> --all

首先,我建议检查一些标准的东西,比如:

以正确的用户登录系统, 在系统的正确位置拥有正确的私钥, 尝试使用正确的用户名、主机名和端口进行连接, 将公钥放在外部服务器中正确的位置(并为正确的用户), 重新启动计算机上的SSH服务:

service ssh restart

(或者以另一种方式取决于您如何管理系统中的服务…)

这对我来说已经足够了。

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