首页 文章

Heroku 'Permission denied (publickey) fatal: Could not read from remote repository'困境

提问于
浏览
135

我已经搜索了好几个小时,希望找到一个解决方案来解决我看似容易解决的问题 . 这并不是说我的搜索没有发现,而是我的搜索出现了许多不同的解决方案 - 其中没有一个有效 .

无论如何,我根本无法从我的Mac上推送,拉取或从我的Heroku存储库中取出 . 每一次尝试都给了我(好像在嘲笑我)以下错误:

'权限被拒绝(publickey) . 致命:无法从远程存储库读取 .

我已尝试(并重新尝试)以多种不同方式修复它 . 正如我所说,过去两天我花了很多时间寻找答案 . 以下是我尝试过的一些事情:

  • heroku键:清除后跟heroku键:添加

  • 使用'ssh-keygen -t rsa'自行重新生成ssh密钥

  • 清除我的.ssh目录,然后是heroku键:clear,然后生成一个ssh密钥

  • 在heroku上删除我的应用程序并重新创建一个(幸运的是那里没有多少)

我可以从我的GitHub存储库中获取,所以我知道它不是网络连接(ping heroku也可以) .

作为一个临时解决方案(我希望不会成为永久解决方案),我已登录到我的Ubuntu Amazon AWS ec2实例 . 从Heroku拉出和推动工作完美 . 出于这个原因,我仍然觉得我的Mac上的ssh键问题就好了 . 这两个键都显示在我的Heroku帐户下 . 密钥结束时的电子邮件地址是否重要?

编辑:我可以从GitHub推送和拉(但我没有使用ssh),为什么不是Heroku?

在这一点上,我愿意尝试任何事情 . 谢谢!

14 回答

  • 3

    我知道这已经得到了解答 . 但我想补充一下我的解决方案,因为它可能对将来的其他人有所帮助 .

    常见的密钥错误是: Permission denied (publickey) . 您可以使用 keys:add 通知Heroku您的新密钥来解决此问题 .

    简而言之,请按照以下步骤操作:https://devcenter.heroku.com/articles/keys

    First you have to create a key if you don't have one:

    ssh-keygen -t rsa
    

    Second you have to add the key to Heroku:

    heroku keys:add
    
  • 0

    我以为我会分享我找到了自己问题的答案 .

    写出我的问题让我更加清楚,我进一步调查了我认为我的问题所处的位置:ssh键

    事实证明我是对的 . 问题不在于密钥本身,而在于我没有将其添加到我当地的Mac已知ssh密钥列表中 . 因此即使我的Heroku帐户上传了正确的密钥,我的Mac也无法通过它进行身份验证,因为它无法在我的计算机上找到该密钥 . 解决方案?

    ssh-add ~/.ssh/id_rsa
    #and, to confirm it's been added to the known list of keys
    ssh-add -l
    

    我想赞扬https://help.github.com/articles/error-permission-denied-publickey是一个很好的参考 .

  • 269

    我有完全相同的错误(在Windows 7上),原因是不同的 . 我以不同的方式解决了它,所以我想我会在这里为其他人添加原因和解决方案 .

    即使错误似乎指向heroku真的错误是说 "Heroku can't get to the git repository" . 我发誓我在所有服务器上都有相同的密钥,因为我创建了它并同时将其上传到一个接一个 .

    花了将近一天的时间后,我意识到因为git只显示指纹而不是实际的键 . 我无法验证它与我的HD或heroku上的键匹配 . 我查看了已知的hosts文件并猜测...它显示了每个服务器的密钥,我能够清楚地看到git和heroku公钥不匹配 .

    1)我删除了我的密钥文件夹中的所有文件,github使用他们的网站的密钥,以及来自heroku的密钥使用git bash和命令 heroku keys:clear

    2)按照github的说明here生成新密钥对并将公钥上传到git

    3)使用 git bash- heroku keys:add 将相同的密钥上传到heroku .

    现在 git push heroku master 有效 .

    多么噩梦,希望这对某人有所帮助 .

    布赖恩

  • 0

    我遇到的问题是我只使用https作为我的GitHub帐户 . 我需要确保我的GitHub帐户已设置为ssh访问,并且GitHub和heroku都使用相同的公钥 . 这些是我采取的步骤:

    • 导航到〜/ .ssh目录并删除id_rsa和id_rsa.pub(如果它们在那里) . 我开始使用新密钥,但可能没有必要 .
    $ cd ~/.ssh
    $ rm id_rsa id_rsa.pub
    
    • 按照gitHub上的步骤进行generate ssh keys

    • 登录heroku,创建一个新站点并添加您的公钥:

    $ heroku login
    ...
    $ heroku create
    $ heroku keys:add
    $ git push heroku master
    
  • 2

    我在linux ubuntu上有相同的情况并且修复了它,似乎操作系统在/root/.ssh/和home / user / .ssh / dir之间混淆了,我做的是:

    • 从root和home / user .shh目录中删除了所有密钥 .

    • generated a new key一定要注意创作的路径(/home/you/.ssh/id_rsa)或(/root/.ssh/id_rsa)

    • 检查heroku键 heroku keys

    • 如果那里的钥匙清楚 heroku keys:clear

    • heroku keys:add 现在在这里,如果heroku找不到密钥并要求生成一个正确的no,这意味着你有与我相同的问题,请执行这样的添加命令 heroku keys:add /root/.ssh/id_rsa.pub 你将添加的路径将是一个你在第2步中得到的 .

    • 现在尝试 git push heroku master

  • 120

    我在Windows 8上的方式

    • 使用ssh-keygen将目录添加到系统PATH变量,通常是C:\ Program Files(x86)\ Git \ bin

    • 打开CMD,转到C:\ Users \ Me \

    • 生成SSH密钥 ssh-keygen -t rsa

    输入要保存密钥的文件(//.ssh/id_rsa): . ssh / id_rsa(将默认的错误路径更改为.ssh / somegoodname_rsa)

    从列表中选择创建的密钥

    • 转到您的app目录,写一些漂亮的代码

    • 初始化git repo git init git add . git commit -m 'chore(release): v0.0.1

    • Create Heroku application heroku create

    • 部署您的应用 git push heroku master

    • 打开你的应用 heroku open

  • 17

    有一个类似的问题,并尝试了很多东西 . 最终对我有用的是在Windows上安装Gnu(https://github.com/bmatzelle/gow/releases),并确保它在该目录中使用ssh工具而不是使用Git的那个 . 一旦安装测试(确保它在你的环境PATH中它是否具有Git \ bin)

    C:\Git\htest2>which ssh
    C:\Program Files (x86)\Gow\bin\ssh.BAT
    

    我使用了这里描述的腻子和选美:http://rubyonrailswin.wordpress.com/2010/03/08/getting-git-to-work-on-heroku-on-windows-using-putty-plink-pageant/

    将密钥发送到heroku后(heroku密钥:添加c:\ Users \ Person.ssh \ id_rsa.pub),使用

    ssh -v <username>@heroku.com
    

    并确保您的堆栈显示使用Putty - 即工作堆栈:

    Looking up host "heroku.com"
    Connecting to 50.19.85.132 port 22
    Server version: SSH-2.0-Twisted
    Using SSH protocol version 2
    **We claim version: SSH-2.0-PuTTY_Release_0.62**
    Using Diffie-Hellman with standard group "group1"
    Doing Diffie-Hellman key exchange with hash SHA-1
    Host key fingerprint is:
    ssh-rsa 2048 8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1f:c8:60:ad
    Initialised AES-256 SDCTR client->server encryption
    Initialised HMAC-SHA1 client->server MAC algorithm
    Initialised AES-256 SDCTR server->client encryption
    Initialised HMAC-SHA1 server->client MAC algorithm
    Pageant is running. Requesting keys.
    Pageant has 1 SSH-2 keys
    Using username "*--ommitted for security--*".
    **Trying Pageant key #0**
    Authenticating with public key "rsa-key-20140401" from agent
    Sending Pageant's response
    Access granted
    Opened channel for session
    Server refused to allocate pty
    Server refused to start a shell/command
    FATAL ERROR: Server refused to start a shell/command
    

    一个以前运行并失败的:

    C:\Git\htest2>ssh -v <username>@gmail.com@heroku.com
    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/Users/Person/.ssh/identity type -1
    debug1: identity file /c/Users/Person/.ssh/id_rsa type 1
    debug1: identity file /c/Users/Person/.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/Users/Person/.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/Users/Person/.ssh/identity
    debug1: Offering public key: /c/Users/Person/.ssh/id_rsa
    debug1: Server accepts key: pkalg ssh-rsa blen 277
    debug1: Trying private key: /c/Users/Person/.ssh/id_dsa
    debug1: No more authentication methods to try.
    Permission denied (publickey).
    
  • 2

    你需要输入以下命令来创建一个新的ssh密钥--ssh-keygen -t rsa

    然后你需要添加: - heroku键:添加

    然后,如果你键入 - heroku打开

    问题已经解决了 .

    无论如何它对我有用,你可以尝试一下......

  • 2

    我得到了同样的错误,因为我有4个ssh-key,所以我试着跟随:

    ssh-keygen -t rsa
    heroku keys:add
    

    然后,四个选项显示:

    1) github_rsa.pub
    2) id_boot2docker.pub
    3) id_rsa.pub
    4) sshkey.pub
    

    我选择最新的3)

    然后,我修复了错误 .

  • 0

    我用这种方法来解决这个问题也许你可以尝试一下

    “启用ssh-agent”

    • 下载git

    http://git-scm.com/

    • 安装它

    • 启用ssh-agent

    C:\ Program Files \ Git \ cmd

    启动的ssh-agent

    我代理启用后消息消失希望这会对你有所帮助

  • 1

    我想添加另一个解决方案,因为我在这里没有看到它 . 我的问题是heroku链接到错误的URL(因为我一直在玩url名称) . 编辑远程网址解决了我的问题:

    git remote set-url heroku <heroku-url-here>
    
  • 1

    我遇到过同样的问题 . 我试图重置我的密钥,因为每个人都说,但它仍然没有奏效 . 因为我重命名了应用程序 .

    所以我做的是重置我的键,并从控制台重命名应用程序 . 查看此问题以获取更多信息:Heroku push app problem

  • 6

    所以这么简单的解决方案,转到c:/Users/user_name/.ssh/并删除所有发布/私钥对,这样heroku将为您生成密钥 .

  • 31

    我有一个类似的heroku ssh错误,我无法解决 .

    作为一种解决方法,我使用了新的heroku http-git功能(http传输为"heroku" remote而不是ssh) . 详情:https://devcenter.heroku.com/articles/http-git

    (简短版本:如果你有一个项目已经设置了标准方式,运行heroku git:remote --http-init将“heroku”remote更改为http . )

    如果您没有时间修复/解决ssh问题,请快速解决问题 .

相关问题