无法将代码通过'git push'命令推送到Heroku

6
我在家里不能像平常一样推送代码到Heroku。我已经尝试使用两个不同的帐户(家庭和工作),在不同的应用程序上,使用了不同的SSH密钥。这不是一个受损的仓库,因为它从我的工作电脑中运行正常。(实际上,我通常通过ssh连接到工作计算机并从那里部署来解决这个问题,但那里停电了,所以这个周末我无法这样做!)
首先,这与其他几十个类似的问题不同,主要是因为我没有得到“错误”信息。
错误(非)消息:
$ 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秒。请注意保留HTML标记。
$ 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)路由器中的内容,该路由器设置为不阻止任何东西。我没有使用代理。我可以从这里成功地部署到GitHub。出于某种原因,我甚至无法连接到Heroku。我知道我的公钥没有被拒绝,而且它根本没有连接上,因为日志中没有显示任何内容,也没有任何活动:

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

更新:我已向Heroku提交了一个关于这个问题的工单,并正在等待他们的支持回复。如果他们能够解决这个问题,我将在这里回答。

一个猜测 -- 降低你的 MTU。 - Nitzan Shaked
另外,当您运行 ssh -vvv git@heroku.com 时,tcpdump 显示了什么? - Nitzan Shaked
MTU在这里与办公室相同(1500字节);tcpdump显示了我所期望的ssh -vvv git@heroku.comgit push heroku master的情况,即一些介绍性的数据包交换,然后是一段“无声电台”时间,对应于命令挂起,接着是一些数据包交换和断开连接。 - Two-Bit Alchemist
在服务器端是否有任何可能导致挂起的东西?比如.bashrc文件中的一些echo或等待输入的操作吗?我曾经见过这种错误,当ssh shell的.bashrc不干净时就会出现这种情况。例如,一个很好的测试是(http://serverfault.com/a/201158/783):`ssh -t git@heroku.com /bin/sh`(甚至可以替换远程的.bashrc文件:http://superuser.com/a/503785/141) - VonC
另外,还要补充的是,在heroku logs中没有任何东西甚至表明我已经到达服务器了。据我所知,连接从未完全建立。 - Two-Bit Alchemist
显示剩余3条评论
3个回答

6
似乎是与您的安全证书有关的问题。Heroku不支持ECDSA密钥, 根据他们的文档。我建议创建一个新的RSA SSH密钥,仅用于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来解决这个问题。感谢你帮我发现这个疏忽! - Two-Bit Alchemist
谢谢,很高兴能帮忙! - danielricecodes

0

试试这个:

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

0
我刚遇到了类似的问题。在验证了我拥有正确的RSA密钥格式并可以通过ssh连接到heroku之后,当我尝试推送时仍然出现“fatal: unable to connect to git.heroku.com:”错误。以下是对我有效的解决方法:
首先检查是否已设置远程。
git remote -v

如果存在远程仓库,则可以使用 git remote rm [remote name] 命令将其删除。例如,在我的情况下,远程仓库的名称是 'heroku'。
git remote rm heroku

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

heroku git:remote --ssh-git

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接