简体   繁体   English

无法将 git 推送到远程存储库:(SSH 错误)

[英]Cannot push git to remote repository: (SSH error)

When I attempt to push to my heroku.com remote git repository, i get this message:当我尝试推送到我的 heroku.com 远程 git 存储库时,我收到此消息:

ssh: connect to host heroku.com port 22: Connection refused

I can easily work with my repository on github with the same ssh key. 我可以 使用相同的 ssh 密钥轻松使用 github 上的存储库。

Entering:输入:

$ssh git@github.com    #outputs: success message
$ssh git@heroku.com    #outputs: ssh: connect to host heroku.com port 22: Connection refused

I'm on Mac OS 10.6.我在 Mac OS 10.6 上。 And I'm very clueless slowly learning!而且我 很无能 慢慢学习!

UPDATE:更新:

$telnet heroku.com 22

gives this output:给出这个 output:

Trying 75.101.145.87...
telnet: connect to address 75.101.145.87: Connection refused
Trying 75.101.163.44...
telnet: connect to address 75.101.163.44: Connection refused
Trying 174.129.212.2...
telnet: connect to address 174.129.212.2: Connection refused
telnet: Unable to connect to remote host

Connection refused is a TCP error message saying that that server isn't running a service on that port. 连接被拒绝是一条TCP错误消息,表明该服务器未在该端口上运行服务。 In this case, perhaps heroku.com's SSH server wasn't running. 在这种情况下,heroku.com的SSH服务器可能没有运行。

If you haven't given them your key, or you use the wrong private key, ssh will say something like this: 如果您没有给他们您的密钥,或者您使用了错误的私钥,那么ssh会说出这样的内容:

frank@roke$ ssh git@heroku.com
Permission denied (publickey).

frank@roke$ ssh -i ~/.ssh/roke-frank.priv git@heroku.com
Permission denied (publickey).

(And the above messages indicate that right now heroku's SSH server is indeed running.) (以上消息表明,目前heroku的SSH服务器确实正在运行。)

Since you're not able to connect to the same server to which I can, perhaps there's a firewall issue. 由于您无法连接到同一台服务器,因此可能存在防火墙问题。 Are you behind a NAT? 您是否在使用NAT? Does your gateway permit connections to port 22 on remote machines? 您的网关是否允许连接到远程计算机上的端口22?

That machine runs a web server too, so try telnet heroku.com 80 to see if you can connect to that machine at all. 该机器也运行Web服务器,因此请尝试telnet heroku.com 80 ,看看是否可以连接到该机器。

It seems ssh-server wasn't working or host was offline. 似乎ssh-server无法正常工作或主机处于脱机状态。 I think it was temporally trouble. 我认为这是暂时的麻烦。

I'm trying now: 我正在尝试:

telnet heroku.com 22
Trying 174.129.212.2...
Connected to heroku.com (174.129.212.2).
Escape character is '^]'.
SSH-2.0-OpenSSH_5.1p1 Debian-5pgsql1

Anyway you can diagnose doing ssh -v git@heroku.com (or -vv) 无论如何,您都可以诊断为执行ssh -v git@heroku.com (或-vv)

You need push your key to heroku. 您需要将钥匙推到heroku。

Because heroku and github are two distinct service. 因为heroku和github是两个不同的服务。 They don't share your key. 他们不共享您的密钥。

I just ran into this on stuff that'd been working for ages and suddenly broke on all my computers and all the people I work with so, if it helps.我刚刚遇到了这个已经工作了很长时间的东西,突然在我所有的电脑和所有和我一起工作的人身上坏了,如果它有帮助的话。 Our problem was that we had our .git/config using @ github urls.我们的问题是我们的.git/config使用 @ github url。

Example: Instead of this示例:而不是这个

[remote "heroku-some-site"]
  url = git@heroku.com:some-site.git
  fetch = +refs/heads/*:refs/remotes/heroku/*

Do this做这个

[remote "heroku-some-site"]
  url = https://git.heroku.com/some-site.git
  fetch = +refs/heads/*:refs/remotes/heroku/*

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM