Git 推进 heroku 主许可被拒绝(public)。致命的: 远程终端意外挂断

请原谅我的失望,我会尽量控制因为 Heroku 使用 SO 作为他们的客户支持(我认为这是劣质的至少可以说)。

在过去的五个小时里,我一直试图让一个应用程序发布,但总是出现问题的关键。我读了几十篇文章,尝试了一条又一条的建议,试图找出 Heroku 在这个愚蠢、完全不透明的过程中搞砸的地方。

我的用例并没有那么难: 我已经为我的 heroku 应用程序创建了一个新的密钥对。我把那把钥匙设成了我的钥匙:

  > heroku keys
=== travis@xxxx.com Keys
ssh-rsa AAAAB3NzaC...avOqfA7ZBd travis@xxxx.com

我可以登录并“创建”一个应用程序(愚蠢的名称,因为它似乎是创建一个 git 回购,而不是任何类型的应用程序)没有问题。但是我试图推动我的应用程序,我得到了:

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

我完全不知道卧槽是怎么回事,我只能用头撞击键盘,没有办法,只能希望万能的谷歌之神能够回答这个问题。而谷歌并没有回答这个问题(好吧,让我收回这句话,我已经看到了十几种回答这个问题的方法)。

对于一个应该很容易的系统来说,这是一个笑话。我喜欢 Heroku 这个主意,但是在花了5英里的时间完成了完全的 abc 0之后,我想这也许是个错误的选择。

34266 次浏览

I've encountered the same issue, and this is my theory as 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.

However, I tried later to ssh into another server using the -i flag 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 master command works. Some conclusions:

  • While ssh will prompt you for the password to an identity file, git will not.
  • If you unlock the identity file with another method, like ssh, it will stay unlocked for your git usage.
  • There doesn't seem to be any documentation 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.

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 jsmith@gmail.com
    
  • 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

Your heroku key and github keys are not in sync.

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

  • Add the key to github.

  • Add the same key to heroku using: heroku keys:add

If none of the other solutions work for you, be sure that you are logged in linux shell with your account and not with root account.

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

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.

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

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