当我推送到有效的

当我推送到有效的

本文介绍了当我推送到有效的 SSH 地址时,为什么 git 无法解析主机名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Heroku 上部署一个应用程序,所以我从一个存储库创建了一个 Heroku 应用程序,然后执行 git push heroku master.当我这样做时,它不断给我错误:

I am deploying an app on Heroku so I created a Heroku app from a repo and then did git push heroku master. When I do this it keeps giving me the error:

!  Your key with fingerprint xxx is not authorized to access heroku-app.

fatal: Could not read from remote repository.

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

我尝试了各种更改 SSH 密钥的方法,包括删除所有密钥和创建新密钥.它仍然给我同样的错误.我已经添加了 Heroku 的密钥.

I tried various things with changing my SSH keys including deleting them all and creating new ones. Still it gives me the same error. I have added the key to Heroku.

然后我尝试运行 ssh -vT [email protected]:heroku-app.git 结果是:

Then I tried running ssh -vT [email protected]:heroku-app.git and the result was:

OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 53: Applying options for *
ssh: Could not resolve hostname heroku.com:heroku-app.git: nodename nor servname provided, or not known

我无法弄清楚该错误指向什么.主机名绝对有效.SSH 配置文件中是否可能没有我需要的内容?任何想法都会很棒,因为我今天花了好几个小时试图让它发挥作用,但无济于事.

I cannot figure out what that error is pointing to. The hostname is definitely valid. Is it possible I am don't have something I need in the SSH config file? Any ideas would be fantastic because I have spent quite a few hours today trying to get this to work without avail.

推荐答案

[email protected]:heroku-app.git 是一个 SCP 格式.

它依赖于带有heroku.com"条目的~/.ssh/config 文件,该条目指定用户、实际主机名,以及如果需要,私钥/公钥路径.

It relies on a ~/.ssh/config file with a 'heroku.com' entry, which specify the user, the actual hostname, and if needed, the private/public key path.

host heroku.com
     user git
     hostname heroku.com
     identityfile ~/.ssh/yourPrivateKey

再次强调:heroku.com:heroku-app.git"中的heroku.com 不是主机名:它是一个条目在 ssh 配置文件中.
您可以将 heroku.com 替换为 xxx:git push xxx:heroku-app.git,前提是您在 ~/.ssh/config 文件.

Again: heroku.com in 'heroku.com:heroku-app.git' is not an hostname: it is an entry in an ssh config file.
You could replace heroku.com by xxx: git push xxx:heroku-app.git, provided you have an xxx entry in the ~/.ssh/config file.

这篇关于当我推送到有效的 SSH 地址时,为什么 git 无法解析主机名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 01:19