当我推送到有效的SSH地址时,为什么git无法解析主机名?

chr*_*ude 6 git ssh heroku ssh-keys git-remote

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

!  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.
Run Code Online (Sandbox Code Playgroud)

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

然后我尝试运行ssh -vT git@heroku.com:heroku-app.git,结果是:

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
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚错误指向的是什么.主机名绝对有效.我可能在SSH配置文件中没有我需要的东西吗?任何想法都会很棒,因为我今天花了很多时间试图让这个工作无济于事.

Von*_*onC 9

git@heroku.com:heroku-app.git是这个ssh地址的SCP格式.

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

host heroku.com
     user git
     hostname heroku.com
     identityfile ~/.ssh/yourPrivateKey
Run Code Online (Sandbox Code Playgroud)

再说一次:heroku.com' heroku.com:heroku-app.git' 不是主机名:它是ssh配置文件中的一个条目.
如果文件中有xxx条目,则可以替换heroku.comxxx:.git push xxx:heroku-app.git~/.ssh/config

  • @chromedude非常欢迎你.不要忘记你不需要在''git@heroku.com:...`'中使用'`git`',因为用户'`git`'在`〜/ .ssh/config中指定`档案.所以`git push heroku:heroku-app.git`应该足够了(我推荐一个名为`heroku`的条目,而不是`heroku.com`,只是为了确保不与主机名混合) (2认同)