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


当前回答

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

其他回答

视觉指南(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

SourceTree for Windows case

如果你在Windows上使用SourceTree,你需要使用PuTTyGen创建一个新的keypair

您应该插入到的顶部部分的ssh-rsa密钥

Github => Profile=> Settings => SSH and GPG keys => Add Key

然后保存私钥并将其添加到Pageant(它与SourceTree一起运行)

这是所有

这些是我在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

谢谢!

在我的情况下,我重新安装了ubuntu,用户名从以前的改变。在这种情况下,生成的ssh密钥也与之前的密钥不同。

这个问题通过在存储库中复制当前的ssh公钥来解决。密钥将在用户的/home/.ssh/id_rsa.pub中可用

以admin身份执行终端。

如果终端看不到你的.ssh,它就会返回这个错误。