部署英雄代码时的权限被拒绝(publickey)。致命:远端挂起意外 [英] Permission denied (publickey) when deploying heroku code. fatal: The remote end hung up unexpectedly

查看:420
本文介绍了部署英雄代码时的权限被拒绝(publickey)。致命:远端挂起意外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用以下命令行将我的代码部署到heroku:

I'm attempting to deploy my code to heroku with the following command line:

git push heroku master

但会出现以下错误:

Permission denied (publickey).
fatal: The remote end hung up unexpectedly

我已经上传了我的公共SSH密钥,但是它仍然出现这个错误。

I have already uploaded my public SSH key, but it still comes up with this error.

推荐答案

你必须将你的公钥上传到Heroku:

You have to upload your public key to Heroku:

heroku keys:add ~/.ssh/id_rsa.pub

如果没有公钥,Heroku会提示您自动添加一个无缝的工作。只需使用:

If you don't have a public key, Heroku will prompt you to add one automatically which works seamlessly. Just use:

heroku keys:add

要清除以前的所有键,请执行以下操作:

To clear all your previous keys do :

heroku keys:clear

显示所有现有的密钥:

heroku keys

编辑:

上面似乎没有为我工作。我已经把 HOME 环境变量搞乱了,所以SSH正在错误的目录中搜索密钥。

The above did not seem to work for me. I had messed around with the HOME environment variable and so SSH was searching for keys in the wrong directory.

确保SSH检查正确目录中的密钥:

To ensure that SSH checks for the key in the correct directory do :

ssh -vT git@heroku.com

哪些将显示以下(Sample)行

Which will display the following ( Sample ) lines

OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Connecting to heroku.com [50.19.85.156] port 22.
debug1: Connection established.
debug1: identity file /c/Wrong/Directory/.ssh/identity type -1
debug1: identity file /c/Wrong/Directory/.ssh/id_rsa type -1
debug1: identity file /c/Wrong/Directory/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version Twisted
debug1: no match: Twisted
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Host 'heroku.com' is known and matches the RSA host key.
debug1: Found key in /c/Wrong/Directory/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /c/Wrong/Directory/.ssh/identity
debug1: Trying private key: /c/Wrong/Directory/.ssh/id_rsa
debug1: Trying private key: /c/Wrong/Directory/.ssh/id_dsa
debug1: No more authentication methods to try.

权限被拒绝(publickey)。

Permission denied (publickey).

从上面可以看到,ssh查找 /c/Wrong/Directory/.ssh 目录,这不是我们刚刚添加到heroku的公钥的地方(使用 heroku键:add〜/ .ssh / id_rsa.pub ) (请注意,在Windows OS中是指win 7/8中的 HOME code> C:\Users\UserName

From the above you could observe that ssh looks for the keys in the /c/Wrong/Directory/.ssh directory which is not where we have the public keys that we just added to heroku ( using heroku keys:add ~/.ssh/id_rsa.pub ) ( Please note that in windows OS ~ refers to the HOME path which in win 7 / 8 is C:\Users\UserName )

要查看您当前的主目录,请执行以下操作: echo $ HOME echo%HOME%(Windows)

To view your current home directory do : echo $HOME or echo %HOME% ( Windows )

要正确设置您的 HOME 目录(正确地,我的意思是父目录 .ssh 目录,以便ssh可以看对于正确目录中的密钥)请参阅以下链接:

To set your HOME directory correctly ( by correctly I mean the parent directory of .ssh directory, so that ssh could look for keys in the correct directory ) refer these links :


  1. SO关于如何永久设置Unix环境变量的答案

SO关于ssh在错误的目录中查找密钥的问题解决方案相同。

这篇关于部署英雄代码时的权限被拒绝(publickey)。致命:远端挂起意外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆