GitHub:权限被拒绝(公钥)。 fatal:远端意外挂断

发布于 2024-09-17 01:22:43 字数 728 浏览 9 评论 0原文

我已按照以下说明上传项目。

全局设置:

 Download and install Git
  git config --global user.name "Your Name"
  git config --global user.email [email protected]
  Add your public key


Next steps:

  mkdir tirengarfio
  cd tirengarfio
  git init
  touch README
  git add README
  git commit -m 'first commit'
  git remote add origin [email protected]:tirenga/tirenga.git
  git push origin master

但我收到此错误:

权限被拒绝(公钥)。致命的: 远端意外挂断

I have followed these instructions below to upload a project.

Global setup:

 Download and install Git
  git config --global user.name "Your Name"
  git config --global user.email [email protected]
  Add your public key


Next steps:

  mkdir tirengarfio
  cd tirengarfio
  git init
  touch README
  git add README
  git commit -m 'first commit'
  git remote add origin [email protected]:tirenga/tirenga.git
  git push origin master

But I get this error:

Permission denied (publickey). fatal:
The remote end hung up unexpectedly

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(22

嘦怹 2024-09-24 01:22:44

创建 RSA 密钥对后,必须使用以下命令将其添加到 SSH:

ssh-add ~/.ssh/id_rsa

或在创建 rsa 密钥对的任何位置。

after you created the RSA key pair, you must to add it to SSH using:

ssh-add ~/.ssh/id_rsa

or wherever you created your rsa key pair.

来日方长 2024-09-24 01:22:44

是的,这是一个公钥问题。
我是 windows 用户,下面的页面可以帮助我解决此问题。

http://help.github.com/win-set-up-git /

更准确地说,这个链接应该有帮助

https://help.github.com/articles/error-permission-拒绝公钥

Yes, It's a public key Problem.
I'm a windows user,and the page below help me resolve this problem.

http://help.github.com/win-set-up-git/

more precisely this link should be helpful

https://help.github.com/articles/error-permission-denied-publickey

一身仙ぐ女味 2024-09-24 01:22:44

对我来说,问题是通过 sudo 执行克隆。

如果您克隆到具有用户权限的目录(/home/user/git),它将正常工作。

(说明:以超级用户身份运行命令将无法使用与以用户身份运行命令相同的公钥。因此 Github 拒绝连接。)

此解决方案需要已设置 SSH 密钥: https://help.github.com/articles/generate-ssh-keys

For me the problem was the execution of clone via sudo.

If you clone to a directory where you have user permission ( /home/user/git) it will work fine.

(Explanation: Running a command as superuser will not work with the same public key as running a command as user. Therefore Github refused the connection.)

This solution requires a SSH key already to be set up: https://help.github.com/articles/generating-ssh-keys

我爱人 2024-09-24 01:22:44

使用您的用户名和存储库名称键入以下命令:

git clone https://github.com/{user name}/{repo name}

在 Ubuntu 中,这非常有效。

Type the following command using your username and repository name:

git clone https://github.com/{user name}/{repo name}

in Ubuntu this works perfectly.

万人眼中万个我 2024-09-24 01:22:44

经过很长时间的教程,我得到了解决方案。

我遵循了此链接上的 github 教程 -> https://help.github.com/articles/error-permission-denied-publickey 我能够在每一步中进行连接。
但是当我尝试 git push -u origin master 时,我收到了此错误:

权限被拒绝(公钥)。致命:无法从远程读取
存储库。

请确保您拥有正确的访问权限

这就是我修复它的方法!!
使用终端转到项目目录并检查它,

$git remote -v

您将得到如下内容:

origin  ssh://[email protected]/yourGithubUserName/yourRepo.git (fetch)
origin  ssh://[email protected]/yourGithubUserName/yourRepo.git (push)

如果您使用任何不同的内容,则 [email protected],通过键入以下命令打开 git 目录中的配置文件:

vi .git/config

并配置行

[remote "origin"]

url = ssh://[email protected]/yourGithubUserName/yourRepo.git

fetch = +refs/heads/*:refs/remotes/origin/

I got a solution after a long time in tutorials.

I followed the github tutorial on this link -> https://help.github.com/articles/error-permission-denied-publickey and I was able to connect in every step.
But when I was trying to git push -u origin master I got this error:

Permission denied (publickey). fatal: Could not read from remote
repository.

Please make sure you have the correct access rights

Thats how I`ve fixed it!!
Go to the project directory using the Terminal and check it out

$git remote -v

You will get something like this:

origin  ssh://[email protected]/yourGithubUserName/yourRepo.git (fetch)
origin  ssh://[email protected]/yourGithubUserName/yourRepo.git (push)

If you are using anything different then [email protected], open the config file on git directory by typing the command:

vi .git/config

And configure the line

[remote "origin"]

url = ssh://[email protected]/yourGithubUserName/yourRepo.git

fetch = +refs/heads/*:refs/remotes/origin/
最近可好 2024-09-24 01:22:44

就我而言,我必须为另一位用户设置公钥,因为我已经为我的主用户设置了公钥。一旦我切换用户并执行上面链接中的命令,我就能够毫无问题地执行测试服务器的设置。

In my case, I had to setup the public key for another user, as I already had one for my main user. once I switched users and performed the commands in the link above I was able to perform the setup for my test server without a problem.

半仙 2024-09-24 01:22:44

我遇到了这个问题,但是上面的解决方案都不起作用。我可以克隆和获取,但无法推送。最终,我发现问题出在我的 .git/config 中的 url 中,它应该是:(

[email protected]:<username>/<project>

而不是 ssh://github.com/< ;用户名>/<项目>.githttps://github.com/<用户名>/<项目>.git)。

I had this problem, but none of the solutions above worked. I could clone and fetch but couldn't push. Eventually, I figured out the problem was in the url in my .git/config, it should be:

[email protected]:<username>/<project>

(not ssh://github.com/<username>/<project>.git or https://github.com/<username>/<project>.git).

缘字诀 2024-09-24 01:22:44

鉴于这里的答案都不适合我,我最终找到了使用 ssh -vT [电子邮件受保护]

就我而言,失败是由于使用 DSA 密钥而不是 RSA 造成的,显然我的 SSH 客户端不再允许这样做。

debug1:跳过 ssh-dss 密钥 /c/Users/USER/.ssh/id_dsa,因为它不在 PubkeyAcceptedKeyTypes 中

解决方案是将其添加到 .ssh/config:

Host *
    PubkeyAcceptedKeyTypes +ssh-dss

这优雅地将 ssh-dss 密钥类型附加到所有现有的接受的公钥类型完成此操作后,git 现在可以毫无问题地 ssh 到 Bitbucket 中。

Given that none of the answers here worked for me, I finally tracked down my issue connecting to Bitbucket (or Github, doesn't matter in this case) with ssh -vT [email protected].

In my case, the failure was due to using a DSA key instead of RSA, and apparently my SSH client no longer allows that.

debug1: Skipping ssh-dss key /c/Users/USER/.ssh/id_dsa for not in PubkeyAcceptedKeyTypes

The solution was to add this to .ssh/config:

Host *
    PubkeyAcceptedKeyTypes +ssh-dss

This elegantly appends the ssh-dss key type to all existing accepted public key types and after this was done, git can now ssh into Bitbucket no problem.

像极了他 2024-09-24 01:22:44

我的问题是,每次我在 Mac 终端上输入 ssh-keygen 时,我都试图为我的 ssh 密钥指定一个具体名称

我通过保留“ssh-keygen”生成的名称= id_rsa 解决了这个问题。您最终会在 Mac 上的 .ssh 文件夹中得到 2 个密钥:id_rsa(您的私钥)和 id_rsa.pub(您的公钥) 。然后我将 id_rsa.pub 中的代码复制并保存到我的 GitHub 帐户设置中,就是这样。问题解决了。

My issue was that I was trying to give my ssh key a SPECIFIC NAME every time I entered ssh-keygen on my mac terminal.

I solved the issue by just leaving the name that "ssh-keygen" generates = id_rsa. You'll end up with 2 keys in your .ssh folder on a mac, id_rsa, which is your private key, and the id_rsa.pub, which is your public key. Then I copied and saved the code from id_rsa.pub into my GitHub account settings, and that was it. Problem solved.

心凉 2024-09-24 01:22:44

如果您在计算机上安装了 git,这是一个很好的选择:

http://help.github。 com/mac-set-up-git/

A good one if you have installed git on your computer:

http://help.github.com/mac-set-up-git/

猫腻 2024-09-24 01:22:44

添加公钥是解决方案。要生成 ssh 密钥: https://help.github.com /articles/generating-ssh-keys 有分步说明。

但是,如果未以正确的方式生成密钥,问题可能仍然存在。
我发现这也是一个有用的链接: https://help.github.com /articles/error-permission-denied-publickey

在我的例子中,问题是我在不使用 sudo 的情况下生成 ssh-key,但在使用 git 命令时我需要使用 sudo。
上面链接中的评论“如果您在没有 sudo 的情况下生成 SSH 密钥,那么当您尝试使用 sudo git push 等命令时,您将不会使用您生成的 SSH 密钥。”帮助了我。

因此,解决方案是我必须将 sudo 与密钥生成命令和 git 命令一起使用。
或者对于其他人来说,当他们在任何地方都不需要 sudo 时,不要在两个步骤中的任何一个中使用它。 (密钥生成和 git 命令)。

Adding public key is the solution.For generating ssh keys: https://help.github.com/articles/generating-ssh-keys has step by step instructions.

However, the problem can persist if key is not generated in the correct way.
I found this to be a useful link too: https://help.github.com/articles/error-permission-denied-publickey

In my case the problem was that I was generating the ssh-key without using sudo but when using git commands I needed to use sudo.
This comment in the above link "If you generate SSH keys without sudo, then when you try to use a command like sudo git push, you won't be using the SSH key you generated." helped me.

So, the solution was that I had to use sudo with both key generating commands and git commands.
Or for others, when they don't need sudo anywhere, do not use it in any of the two steps. (key generating and git commands).

悲凉≈ 2024-09-24 01:22:44

在 Windows 中运行 SSH 或 Git Clone 时,我遇到了类似的问题。以下发现有助于解决我的问题:

  • 当您运行“rhc setup”或其他 ssh 方法来生成 ssh 密钥时,它将在您的主文件夹中的 .ssh 文件夹中创建私钥文件 id_rsa,默认为 C:\User\UserID
  • Git对于 Windows,其安装目录中有自己的 .ssh 文件夹。当你运行 git/ssh 时,它会在此文件夹中查找私钥文件 id_rsa
  • 通过将 id_rsa 从主文件夹 .ssh 文件夹复制到 git 安装目录中的 .ssh 文件夹解决了问题

另外,我认为有一种方法“告诉“git 使用主文件夹中的默认 .ssh 文件夹,但仍需要弄清楚如何操作。

I faced a similar issue when running SSH or Git Clone in Windows. Following findings helps to solve my problem:

  • When you run “rhc setup” or other ssh methods to generate ssh key, it will create the private key file id_rsa in .ssh folder in your home folder, default is C:\User\UserID
  • Git for windows has its own .ssh folder in its installation directory. When you run git/ssh, it will look for private key file id_rsa in this folder
  • Solved the problem by copying id_rsa from the home folder .ssh folder to the .ssh folder in the git installation directory

Also, I think there a way to “tell” git to use the default .ssh folder in home folder but still need to figure out how.

云仙小弟 2024-09-24 01:22:44

对我来说,它是这样工作的:

在 GitHub 中,我将 ssh 链接更改为 https ,然后给出以下命令:

$ git init
$ git remote add origin https:...
$ git add .
$ git commit -m "first commit"
$ git push origin master

For me, it worked like this:

In GitHub I changed the ssh link to https, and then gave the following commands:

$ git init
$ git remote add origin https:...
$ git add .
$ git commit -m "first commit"
$ git push origin master
陌若浮生 2024-09-24 01:22:44

您可以尝试将连接类型从 ssh 更改为 https。

  1. nano project_path/.git/config
  2. 替换[电子邮件] protected]:用户名/repository.githttps://[email protected]/username/repository_name.git
  3. 保存文件 ctrl + o

之后你可以尝试 git无需公钥即可拉取

You can try change your type connection to branch from ssh to https.

  1. nano project_path/.git/config
  2. Replace [email protected]:username/repository.git to https://[email protected]/username/repository_name.git
  3. Save file ctrl + o

After that you can try git pull without publickey

橘香 2024-09-24 01:22:44

在 Windows 应用商店上使用 ubuntu

Linux 的 Windows 子系统

,您的 git Push 将在不同的帐户上工作。

Use ubuntu on windows store

windows subsystem for linux

, your git push will work across different accounts.

笑忘罢 2024-09-24 01:22:44

如果您使用的是 Linux 机器,请检查

  • 是否安装了 Openssh(
  • 如果安装了),那么您是否有现有的公钥,否则您必须生成一个。
  • 您的公钥是否已添加到您的 github 帐户中。

生成新的 SSH 密钥并将其添加到我的 Github 帐户解决了我的问题。
您可以查看此页面了解更多详细信息。 Git 帮助

If you are using a linux machine then check,

  • do you have Openssh installed
  • if you do, then do you have an existing public key otherwise you'll have to generate one.
  • is your public key added to your github account.

Generating new SSH keys and adding them to my Github account solved my problem.
You can look into this page for more details. GitHelp.

蓝咒 2024-09-24 01:22:44

您需要设置 SSH 密钥。

此 GitHub 页面介绍了如何生成密钥。

如果您有现有密钥,请复制 $HOME/.ssh/id_rsa.pub 并将其粘贴到 GitHub SSH 设置页面

You need to set up SSH keys.

This GitHub page explains how to generate keys.

If you have an existing key, you copy $HOME/.ssh/id_rsa.pub and paste it into the GitHub SSH settings page.

最初的梦 2024-09-24 01:22:44

如果您使用的是 Mac,解决此问题的快速方法是退出 OSX 应用程序并重新登录。

A quick way to fix this if you're using a Mac is to sign out of the OSX app and log back in.

恍梦境° 2024-09-24 01:22:44

我的问题是它不适用于我的私钥密码。

希望对某人有帮助。

My problem was that it didn't work with a passphrase on my private key.

Hope that helps someone.

橙幽之幻 2024-09-24 01:22:44

我今天也有这个问题。
解决方案是设置您的“ssh 密钥”。
点击下面的网址,按照步骤操作就可以解决它。

http://github.com/guides/providing-your-ssh-key

I also have this problem today.
The solution is setting your "ssh key".
Click the url below, follow the steps, then you will sovle it.

http://github.com/guides/providing-your-ssh-key

箜明 2024-09-24 01:22:44

我在 Windows 上也遇到了同样的问题。我从 SSH 切换到 HTTPS 并运行 Git PUSH。

git push -u origin master
Username for 'https://github.com': <Github login email>
Password for <Github login>: xxx

成功的!希望这有帮助。

I had the same issue on windows. I switched from SSH to HTTPS and ran a Git PUSH.

git push -u origin master
Username for 'https://github.com': <Github login email>
Password for <Github login>: xxx

Successful! hope this helps.

魂牵梦绕锁你心扉 2024-09-24 01:22:43

我必须将我的公钥添加到 github。 https://help.github.com/articles/generate-ssh-keys

I had to add my public key to github. https://help.github.com/articles/generating-ssh-keys

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文