【问题标题】:Cannot 'git push' to Heroku无法“git push”到 Heroku
【发布时间】:2021-02-18 01:09:48
【问题描述】:

我不能在我家以正常方式git push 到 Heroku。我尝试在不同的应用程序上使用不同的 ssh 密钥使用两个不同的帐户(家庭和工作)。它不是损坏的存储库,因为它可以在我的工作计算机上运行。 (事实上​​,我通常通过ssh-ing 解决这个问题,以便从那里工作和部署,但是那里的电源停了,所以这个周末我不能这样做!)

首先,这与其他许多类似的问题不同,主要是因为我得到没有错误

错误(非)消息

$ git push heroku master
Connection closed by 50.19.85.132
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

请注意,它会在连接关闭之前恰好挂起 60 秒并显示出来。

$ git push -v heroku master
Pushing to git@heroku.com:myherokuapp.git
Connection closed by 50.19.85.154
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我的尝试

  • heroku keys:add -- 命令成功,密钥被添加到我的帐户中(显示在 heroku.com 上,我收到了电子邮件),但没有任何变化。

  • 完全重新生成密钥。同上。

  • 使用 git remoteheroku git:remote 命令删除和重新添加 git heroku 存储库。 (没有变化。)

  • 调试与ssh -vvv 的连接。 (见下文。)

各种调试命令的输出

$ git remote -v
heroku  git@heroku.com:myherokuapp.git (fetch)
heroku  git@heroku.com:myherokuapp.git (push)

$ heroku apps:info
=== myherokuapp
Git URL:       git@heroku.com:myherokuapp.git
Owner Email:   twobitalchemist@gmail.com
Region:        us
Stack:         cedar
Web URL:       http://myherokuapp.herokuapp.com/

$ ping -c4 50.19.85.132
PING 50.19.85.132 (50.19.85.132) 56(84) bytes of data.
64 bytes from 50.19.85.132: icmp_seq=1 ttl=37 time=48.9 ms
64 bytes from 50.19.85.132: icmp_seq=2 ttl=37 time=49.1 ms
64 bytes from 50.19.85.132: icmp_seq=3 ttl=37 time=47.9 ms
64 bytes from 50.19.85.132: icmp_seq=4 ttl=37 time=49.2 ms

--- 50.19.85.132 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 47.997/48.832/49.245/0.498 ms

$ ping -c4 50.19.85.154
PING 50.19.85.154 (50.19.85.154) 56(84) bytes of data.
64 bytes from 50.19.85.154: icmp_seq=1 ttl=41 time=47.8 ms
64 bytes from 50.19.85.154: icmp_seq=2 ttl=41 time=47.7 ms
64 bytes from 50.19.85.154: icmp_seq=3 ttl=41 time=49.7 ms
64 bytes from 50.19.85.154: icmp_seq=4 ttl=41 time=50.0 ms

--- 50.19.85.154 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 47.746/48.855/50.055/1.059 ms

$ ssh -vvv git@heroku.com
OpenSSH_6.6.1, OpenSSL 1.0.1h 5 Jun 2014
debug1: Reading configuration data /home/user/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to heroku.com [50.19.85.132] port 22.
debug1: Connection established.
[ several lines ommitted ]
debug1: Offering ECDSA public key: /home/user/.ssh/id_ecdsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
[ hangs here ]
Connection closed by 50.19.85.132

附加信息

我正在使用 Arch Linux,在我在工作中使用的同一个 ISP 上(虽然在工作中我们有一个静态 IP),并且我没有防火墙,除了我家 (Netgear) 路由器中内置的防火墙,它设置为 not阻止任何东西。我不在代理后面。我可以从这里很好地部署到 GitHub。无论出于何种原因,我什至无法连接到 Heroku。我知道我的公钥没有被拒绝,而且它根本就没有连接,因为日志没有显示任何内容,也没有任何活动:

$ heroku logs
2014-08-02T02:12:36.883623+00:00 heroku[api]: Enable Logplex by twobitalchemist@gmail.com

更新:我已经就这个问题打开了 Heroku 工单,正在等待他们的支持部门的回复。如果他们能够解决问题,我会在这里回答。

【问题讨论】:

  • 一个疯狂的猜测——降低你的 MTU。
  • 另外,当你运行 ssh -vvv git@heroku.com 时 tcpdump 会显示什么?
  • 这里的MTU和办公室一样(1500字节); tcpdump 显示了我对ssh -vvv git@heroku.comgit push heroku master 的预期,因为发生了什么——即一些介绍性的数据包交换,然后是与命令挂起相对应的一段时间的“无线电静默”,然后是一些数据包交换和断开连接.
  • 服务器端是否有任何可能导致挂起的内容?一个带有一些回声或一些等待输入的操作的.bashrc?当 ssh shell 的 .bashrc 不干净时,我看到了该错误。例如,一个好的测试将是 (serverfault.com/a/201158/783): ssh -t git@heroku.com /bin/sh (或者甚至替换远程 .bashrc: superuser.com/a/503785/141)
  • @VonC 希望这不是我对 Heroku 部署的控制,但我觉得这将被排除在外,因为我可以立即转身并 git push 下班(通过 ssh ) 没有问题。家庭和工作之间肯定存在一些我只是想念或认为不重要的区别(事实上它很重要)。

标签: git heroku ssh


【解决方案1】:

您的安全证书似乎有问题。 Heroku 不支持 ECDSA 密钥 per their documentation。我将创建一个新的 RSA SSH 密钥,用于 heroku 并且仅用于 heroku,将新的公钥发送给他们,然后设置一个 ssh 配置文件以在 SSH 连接到 heroku.com 时提供该密钥。

这是我笔记本电脑上~/.ssh/config 文件中的内容:

Host heroku.com
  IdentityFile /Users/danielrice/.ssh/identity.heroku.danielricecodes
  IdentitiesOnly yes

【讨论】:

  • 很抱歉我这几天没注意这个问题。事实证明这是正确的。不仅如此,我无法生成特殊的 RSA 密钥——它只有在我生成默认的/home/user/.ssh/id_rsa 时才有效。我相信我可以用你的ssh/config 来解决这个问题。感谢您帮助我发现这个疏忽!
  • 谢谢,很高兴为您提供帮助!
【解决方案2】:

试试这个:

git@heroku.com/myherokuapp.git

这可能不是一个有效的网址:

git@heroku.com:myherokuapp.git

或者尝试为您的遥控器使用 https 格式。

https://git@heroku.com:myherokuapp.git

https://git@heroku.com/myherokuapp.git

您可能没有为 git 协议打开正确的端口

注意:git 存储库的常见 URL 方案是:

ssh:// - default port 22
git:// - default port 9418
http:// - default port 80
https:// - default port 443

我添加了这个,因为您正在尝试测试您的 ssh 连接,这可能是端口 22。您可能需要检查端口 9418。

另一种选择是强制 git 使用 https:// 而不是 git://:

git config --global url."https://".insteadOf git://

git config --global url."https://git.somehost.com".insteadOf git://git.somehost.com

【讨论】:

    【解决方案3】:

    我刚刚遇到了类似的问题。在验证我有正确的 RSA 密钥格式并且可以通过 ssh 连接到 heroku 之后,当我尝试推送时,我仍然收到“致命:无法连接到 git.heroku.com:”错误。这对我有用:

    首先检查你是否有遥控器

    git remote -v
    

    如果有远程,则使用 git remote rm [远程名称] 将其删除。例如,在我的情况下,远程名称是“heroku”

    git remote rm heroku
    

    然后使用带有 --ssh-git 标志的 heroku 命令再次添加远程

    heroku git:remote --ssh-git
    

    这是基于这篇 Heroku 支持文章:https://devcenter.heroku.com/articles/git#ssh-git-transport

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-19
      • 2018-10-16
      • 1970-01-01
      • 2011-05-23
      • 2017-06-02
      • 2015-04-11
      • 2016-06-02
      • 1970-01-01
      相关资源
      最近更新 更多