git push heroku master 权限被拒绝(公钥)。致命:远端意外挂断

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12206779/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 14:28:46  来源:igfitidea点击:

git push heroku master Permission denied (publickey). fatal: The remote end hung up unexpectedly

githeroku

提问by Travis Jensen

Please excuse a bit of frustration, which I will try to keep in check since Heroku is using SO as their customer support (which I think it shoddy to say the least).

请原谅有点沮丧,我会尽量保持检查,因为 Heroku 使用 SO 作为他们的客户支持(我认为至少可以说这是劣质的)。

For the last five hours I have been trying to get an application to publish, but invariably something goes wrong with the keys. I've read dozens of articles and tried tip after tip in an effort to figure out where, in the stupid, completely opaque process Heroku is screwing up.

在过去的五个小时里,我一直在尝试发布一个应用程序,但密钥总是出现问题。我已经阅读了数十篇文章并尝试了一个又一个的提示,试图找出在愚蠢的、完全不透明的过程中 Heroku 搞砸的地方。

My use case is not that difficult: I have created a new keypair for my heroku apps. I have set that key to be my key:

我的用例并不难:我为我的 heroku 应用程序创建了一个新的密钥对。我已将该密钥设置为我的密钥:

  > heroku keys
  === [email protected] Keys
  ssh-rsa AAAAB3NzaC...avOqfA7ZBd [email protected]

I can log in and "create" an application (stupid name, since it seems to be creating a git repo, not any sort of app) without problem. But every*freaking* timeI try to push my app, I get:

我可以登录并“创建”一个应用程序(愚蠢的名字,因为它似乎正在创建一个 git repo,而不是任何类型的应用程序),没有问题。但是,每一个*吓坏*时间我试图把我的应用程序,我得到:

  > git push heroku master
  Permission denied (publickey).
  fatal: The remote end hung up unexpectedly

I have no insight into WTF is going on with it; I'm just stuck banging my head against a keyboard with no recourse but to hope the almighty god of Google can answer it. And google isn't answering it (well, let me take that back, I've seen about a dozen ways to answer this).

我不了解 WTF 的进展情况;我只是用头撞着键盘,没有办法,只能希望谷歌的全能神能回答这个问题。谷歌没有回答它(好吧,让我收回那个,我已经看到了大约十几种回答这个问题的方法)。

For a system that is supposed to be easy, this is a joke. I like the idea of Heroku, but after taking five our to get absolutely nothingdone, I'm thinking maybe it is the wrong choice.

对于一个本该简单的系统来说,这是个笑话。我喜欢 Heroku 的想法,但是在花费了 5 个我们却什么也没做之后,我想这可能是错误的选择。

回答by jquintana

There are a variety of solutions around the web. I will try to condense the available options into one post. Please try your connection again after every step.

网络上有各种解决方案。我将尝试将可用选项浓缩到一篇文章中。请在每一步后重新尝试连接。

  • Step 1: Attempt adding you public key to Heroku

    heroku keys:add ~/.ssh/id_rsa.pub // or just heroku keys:add and it will prompt you to pick one of your keys
    
  • Step 2: Generate a new set of SSH keys, then attempt the first step again

    https://help.github.com/articles/generating-ssh-keys

  • Step 3: Verify and/or modify your config file

    vim ~/.ssh/config
    
    Host heroku.com
    Hostname heroku.com 
    Port 22 
    IdentitiesOnly yes 
    IdentityFile ~/.ssh/id_rsa    <--- Should be your public SSH key
    TCPKeepAlive yes 
    User [email protected]
    
  • Step 4: Remove the heroku remote from git, the recreate the connection, adding the remote via heroku create will only be an option for new repositories. Be sure to delete your old repo that you originally attempted to create

     $ git remote rm heroku
     $ heroku create
    
  • Step 5: Reinstall Heroku Toolkit

  • 第 1 步:尝试将您的公钥添加到 Heroku

    heroku keys:add ~/.ssh/id_rsa.pub // or just heroku keys:add and it will prompt you to pick one of your keys
    
  • 第 2 步:生成一组新的 SSH 密钥,然后再次尝试第一步

    https://help.github.com/articles/generating-ssh-keys

  • 第 3 步:验证和/或修改您的配置文件

    vim ~/.ssh/config
    
    Host heroku.com
    Hostname heroku.com 
    Port 22 
    IdentitiesOnly yes 
    IdentityFile ~/.ssh/id_rsa    <--- Should be your public SSH key
    TCPKeepAlive yes 
    User [email protected]
    
  • 第 4 步:从 git 中删除 heroku 远程,重新创建连接,通过 heroku create 添加远程将仅是新存储库的一个选项。请务必删除您最初尝试创建的旧存储库

     $ git remote rm heroku
     $ heroku create
    
  • 第 5 步:重新安装 Heroku 工具包

回答by Robert Christian

Your heroku key and github keys are not in sync.

您的 heroku 密钥和 github 密钥不同步。

  • Determine which key you want to use (recommend creating a new one ie heroku_rsa).

  • Add the key to github.

  • Add the samekey to heroku using: heroku keys:add

  • 确定您要使用的密钥(建议创建一个新密钥,即 heroku_rsa)。

  • 将密钥添加到github。

  • 使用以下命令将相同的密钥添加到 heroku:heroku keys:add

回答by owensmartin

I've encountered the same issue, and this is my theoryas to what's going on:

我遇到了同样的问题,这是我对正在发生的事情的理论

I signed up for Heroku a long time ago, giving them my github public key. When attempting the usual git push heroku master, it goes and looks for my private key, found at ~/.ssh/github_rsa. It then fails silently with the message you posted.

我很久以前就注册了 Heroku,给了他们我的 github 公钥。在尝试通常的 时git push heroku master,它会寻找我的私钥,在~/.ssh/github_rsa. 然后它会以您发布的消息静默失败。

However, I tried later to sshinto another server using the -iflag to specify my "identity file" (i.e. private key), and it prompted me for the password to my private key. Having "unlocked" the private key, the git push heroku mastercommand works. Some conclusions:

但是,我稍后尝试ssh使用该-i标志指定我的“身份文件”(即私钥)进入另一台服务器,它提示我输入我的私钥的密码。“解锁”私钥后,该git push heroku master命令有效。一些结论:

  • While sshwill prompt you for the password to an identity file, gitwill not.
  • If you unlock the identity file with another method, like ssh, it will stay unlocked for your gitusage.
  • There doesn't seem to be anydocumentation on how to permanently remove the password protection on an identity file, including with the common unix command keytool.
  • Above solutions of creating a new public/private key pair seem to be a workaround for this password issue, without knowing that's the problem.
  • 虽然ssh会提示您输入身份文件的密码,但git不会。
  • 如果您使用另一种方法解锁身份文件,例如ssh,它将保持解锁状态以供您git使用。
  • 似乎没有关于如何永久删除身份文件上的密码保护的任何文档,包括使用常用的 unix 命令keytool
  • 上述创建新公钥/私钥对的解决方案似乎是解决此密码问题的方法,但不知道这就是问题所在。

回答by Cabbibo

Permission denied (publickey) when deploying heroku code. fatal: The remote end hung up unexpectedly

部署 heroku 代码时权限被拒绝(公钥)。致命:远端意外挂断

I think this might have your solution, it did for me at least

我认为这可能有您的解决方案,至少对我有帮助

回答by cobberboy

With me, it seemed the problem was that I had ssh-agent running in the background, and the relevant private key had not been added to it.

对我来说,问题似乎是我在后台运行了 ssh-agent,并且没有添加相关的私钥。

ps -afe | grep ssh-agent

ssh-add ~/.ssh/id_rsa_heroku_github

I also had to add the public key to github (manually) and heroku

我还必须将公钥添加到 github(手动)和 heroku

heroku keys:add ~/.ssh/id_rsa_heroku_github.pub

回答by Saulo Falcao

If none of the other solutions work for you, be sure that you are logged in linux shell with youraccount and notwith rootaccount.

如果没有其他的解决方案,为你工作,确保你登录了Linux的外壳,您的帐户并没有帐户。

That way, if you are running with the user that is not the owner of your ssh keys, git will look for the wrong keys to authenticate

这样,如果您与不是 ssh 密钥所有者的用户一起运行,git 将查找错误的密钥进行身份验证