GitHub:权限被拒绝(公钥)。 fatal:远端意外挂断
我已按照以下说明上传项目。
全局设置:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(22)
创建 RSA 密钥对后,必须使用以下命令将其添加到 SSH:
或在创建 rsa 密钥对的任何位置。
after you created the RSA key pair, you must to add it to SSH using:
or wherever you created your rsa key pair.
是的,这是一个公钥问题。
我是 windows 用户,下面的页面可以帮助我解决此问题。
更准确地说,这个链接应该有帮助
Yes, It's a public key Problem.
I'm a windows user,and the page below help me resolve this problem.
more precisely this link should be helpful
对我来说,问题是通过 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
使用您的用户名和存储库名称键入以下命令:
在 Ubuntu 中,这非常有效。
Type the following command using your username and repository name:
in Ubuntu this works perfectly.
经过很长时间的教程,我得到了解决方案。
我遵循了此链接上的 github 教程 -> https://help.github.com/articles/error-permission-denied-publickey 我能够在每一步中进行连接。
但是当我尝试 git push -u origin master 时,我收到了此错误:
这就是我修复它的方法!!
使用终端转到项目目录并检查它,
您将得到如下内容:
如果您使用任何不同的内容,则 [email protected],通过键入以下命令打开 git 目录中的配置文件:
并配置行
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:
Thats how I`ve fixed it!!
Go to the project directory using the Terminal and check it out
You will get something like this:
If you are using anything different then [email protected], open the config file on git directory by typing the command:
And configure the line
就我而言,我必须为另一位用户设置公钥,因为我已经为我的主用户设置了公钥。一旦我切换用户并执行上面链接中的命令,我就能够毫无问题地执行测试服务器的设置。
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.
我遇到了这个问题,但是上面的解决方案都不起作用。我可以克隆和获取,但无法推送。最终,我发现问题出在我的
.git/config
中的url
中,它应该是:(而不是
ssh://github.com/< ;用户名>/<项目>.git
或https://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:(not
ssh://github.com/<username>/<project>.git
orhttps://github.com/<username>/<project>.git
).鉴于这里的答案都不适合我,我最终找到了使用 ssh -vT [电子邮件受保护]。
就我而言,失败是由于使用 DSA 密钥而不是 RSA 造成的,显然我的 SSH 客户端不再允许这样做。
解决方案是将其添加到 .ssh/config:
这优雅地将 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.
The solution was to add this to .ssh/config:
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.
我的问题是,每次我在 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 theid_rsa.pub
, which is your public key. Then I copied and saved the code fromid_rsa.pub
into my GitHub account settings, and that was it. Problem solved.如果您在计算机上安装了 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/
添加公钥是解决方案。要生成 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).
在 Windows 中运行 SSH 或 Git Clone 时,我遇到了类似的问题。以下发现有助于解决我的问题:
另外,我认为有一种方法“告诉“git 使用主文件夹中的默认 .ssh 文件夹,但仍需要弄清楚如何操作。
I faced a similar issue when running SSH or Git Clone in Windows. Following findings helps to solve my problem:
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.
对我来说,它是这样工作的:
在 GitHub 中,我将 ssh 链接更改为 https ,然后给出以下命令:
For me, it worked like this:
In GitHub I changed the
ssh
link tohttps
, and then gave the following commands:您可以尝试将连接类型从 ssh 更改为 https。
nano project_path/.git/config
[电子邮件] protected]:用户名/repository.git
到https://[email protected]/username/repository_name.git
ctrl
+o
之后你可以尝试
git无需公钥即可拉取
You can try change your type connection to branch from ssh to https.
nano project_path/.git/config
[email protected]:username/repository.git
tohttps://[email protected]/username/repository_name.git
ctrl
+o
After that you can try
git pull
without publickey在 Windows 应用商店上使用 ubuntu
,您的 git Push 将在不同的帐户上工作。
Use ubuntu on windows store
, your git push will work across different accounts.
如果您使用的是 Linux 机器,请检查
生成新的 SSH 密钥并将其添加到我的 Github 帐户解决了我的问题。
您可以查看此页面了解更多详细信息。 Git 帮助。
If you are using a linux machine then check,
Generating new SSH keys and adding them to my Github account solved my problem.
You can look into this page for more details. GitHelp.
您需要设置 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.如果您使用的是 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.
我的问题是它不适用于我的私钥密码。
希望对某人有帮助。
My problem was that it didn't work with a passphrase on my private key.
Hope that helps someone.
我今天也有这个问题。
解决方案是设置您的“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
我在 Windows 上也遇到了同样的问题。我从 SSH 切换到 HTTPS 并运行 Git PUSH。
成功的!希望这有帮助。
I had the same issue on windows. I switched from SSH to HTTPS and ran a Git PUSH.
Successful! hope this helps.
我必须将我的公钥添加到 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