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


当前回答

您可以在终端中执行以下操作:

cd ~ / . ssh ssh-keygen -o -t rsa -C "your@email.com" 当提示输入密钥保存位置时,输入:cat id_rsa。Pub | pbcopy 输入并确认您的密码,然后生成新的密钥。 通过运行cat ~/.ssh/id_rsa.pub通知github密钥 复制输出,然后转到github创建一个新的SSH密钥。粘贴复制的内容到文本区域,给它一个合适的标题,然后按ADD键。

现在你可以轻松地进行操作了。

其他回答

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

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

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

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

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

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

我的错误被纠正了。

我碰到了这个错误,因为我需要给我目前的工作目录权限700:

chmod -R 700 /home/ec2-user/

伙计们我是这么干的

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

以admin身份执行终端。

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