我已经连续搜索了好几个小时,以寻找解决我看似容易解决的问题的方法。并不是我的搜索一无所获,而是我的搜索出现了许多不同的解决方案——没有一个奏效。
无论如何,我根本无法从我的 Mac 上推送、拉取或从我的 Heroku 存储库中获取。每次尝试都会给我(好像在嘲笑我)以下错误:
'权限被拒绝(公钥)。致命:无法从远程存储库中读取。
我已经尝试(并重新尝试)以许多不同的方式修复它。正如我所说,过去两天我花了很大一部分时间寻找答案。以下是我尝试过的一些事情:
heroku 键:清除后跟 heroku 键:添加
使用“ssh-keygen -t rsa”自行重新生成 ssh 密钥
清除我的 .ssh 目录,然后是 heroku keys:clear,然后生成一个 ssh 密钥
在heroku上删除我的应用程序并重新创建一个(幸运的是那里没有多少)
我可以很好地从我的 GitHub 存储库中获取,所以我知道这不是网络连接(ping heroku 也可以)。
作为临时解决方案(我希望它不会变成永久解决方案),我已经登录到我的 Ubuntu Amazon AWS ec2 实例。从 Heroku 拉出和推入非常完美。出于这个原因,我仍然觉得问题出在我 Mac 上的 ssh 密钥上。两个密钥都显示在我的 Heroku 帐户下。密钥末尾的电子邮件地址是否重要?
编辑:我可以很好地从 GitHub 推送和拉取(但是我没有使用 ssh),那么为什么不使用 Heroku?
在这一点上,我愿意尝试任何事情。谢谢!
我知道这已经得到了回答。但我想添加我的解决方案,因为它可能在未来对其他人有所帮助..
一个常见的关键错误是:Permission denied (publickey)
。您可以通过使用 keys:add
通知 Heroku 您的新密钥来解决此问题。
简而言之,请按照以下步骤操作:https://devcenter.heroku.com/articles/keys
首先,如果您没有密钥,则必须创建密钥:
ssh-keygen -t rsa
其次,您必须将密钥添加到 Heroku:
heroku keys:add
我只是想我会分享我找到了自己问题的答案。
写下我的问题让我更加清楚,我进一步调查了我认为我的问题出在哪里: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,因为它是一个很好的参考。
Git Bash
(右键单击一个文件夹),然后启动一个 ssh-agent
,这可以通过运行 `ssh-agent`
(注意反引号),然后如上所述添加密钥。我每次启动 Git Bash
/ssh-agent
时都必须这样做,它会忘记添加了什么。
我有完全相同的错误(在 Windows 7 上),原因不同。我以不同的方式解决了它,所以我想我会在这里为其他人添加原因和解决方案。
尽管错误似乎指向 heroku,但实际上错误是在说 "Heroku can't get to the git repository"
。我发誓我在所有服务器上都有相同的密钥,因为我创建了它并同时将它一个接一个地上传到另一个。
在花了将近一天的时间之后,我意识到因为 git 只显示指纹而不是实际的密钥。我无法验证它的密钥是否与我的 HD 或 heroku 上的密钥匹配。我查看了已知的主机文件并猜测是什么......它显示了每个服务器的密钥,我能够清楚地看到 git 和 heroku 公钥不匹配。
1) 我删除了我的密钥文件夹中的所有文件,使用他们的网站从 github 删除了密钥,使用 git bash 和命令 heroku keys:clear
从 heroku 删除了密钥
2)按照github的说明here生成一个新的密钥对并将公钥上传到git
3) 使用 git bash-
heroku keys:add
将相同的密钥上传到 heroku。
现在 git push heroku master
有效。
真是一场噩梦,希望这对某人有所帮助。
布莱恩
我遇到的问题是我只使用 https 作为我的 GitHub 帐户。我需要确保我的 GitHub 帐户已设置为 ssh 访问,并且 GitHub 和 heroku 都使用相同的公钥。这些是我采取的步骤:
导航到 ~/.ssh 目录并删除 id_rsa 和 id_rsa.pub 如果它们在那里。我从新密钥开始,尽管可能没有必要。 $ cd ~/.ssh $ rm id_rsa id_rsa.pub 按照 gitHub 上的步骤生成 ssh 密钥 登录 heroku,创建一个新站点并添加您的公钥: $ heroku login ... $ heroku create $ heroku keys:add $ git push heroku 大师
我在 linux ubuntu 上遇到了同样的情况,只是修复了它,似乎操作系统在 /root/.ssh/ 和 home/user/.ssh/ 目录之间感到困惑,我所做的是:
从 root 和 home/user .shh 目录中删除所有密钥。生成一个新密钥 确保注意创建路径 (/home/you/.ssh/id_rsa) 或 (/root/.ssh/id_rsa) 检查 heroku 密钥 heroku 密钥如果那里的密钥清除 heroku 密钥:清除 heroku keys:add now in here if heroku 找不到密钥并要求生成一个正确的 no,这意味着您遇到与我相同的问题,请执行以下添加命令 heroku keys:add /root/.ssh/id_rsa .pub 您将添加的路径将是您在步骤 2 中获得的路径。现在尝试 git push heroku master
我在 Windows 8 上的方式
在系统PATH变量中添加一个带有ssh-keygen的目录,一般是C:\Program Files (x86)\Git\bin 打开CMD,到C:\Users\Me\ 生成SSH密钥 ssh-keygen -t rsa 在里面输入文件保存密钥(//.ssh/id_rsa):.ssh/id_rsa(将默认的不正确路径更改为 .ssh/somegoodname_rsa)将密钥添加到 Heroku heroku keys:add 从列表中选择创建的密钥 转到您的应用目录,写一些漂亮的代码 Init a git repo git init git add 。 git commit -m 'chore(release): v0.0.1 创建 Heroku 应用程序 heroku create 部署你的应用程序 git push heroku master 打开你的应用程序 heroku open
有类似的问题,并尝试了很多东西。最终对我有用的是在 Windows 上安装 Gnu (https://github.com/bmatzelle/gow/releases),并确保它使用的是该目录中的 ssh 工具,而不是使用 Git 的工具。一旦安装了测试(确保它在你的环境路径中,它在 Git\bin 之前)
C:\Git\htest2>which ssh
C:\Program Files (x86)\Gow\bin\ssh.BAT
我使用了 putty 和 pageant,如下所述: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).
您需要通过键入以下内容来创建新的 ssh 密钥 - ssh-keygen -t rsa
然后你需要添加: - heroku 键:添加
然后如果你输入 - heroku open
问题已解决。
不管怎样,它对我有用,你可以试一试......
我遇到了同样的错误,因为我有 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),最新的
然后,我修复了错误。
我用这个方法来解决这个问题也许你可以试试
“启用 ssh 代理”
下载 git
安装它启用 ssh-agent
C:\Program Files\Git\cmd
启动 ssh 代理
我代理启用后消息消失希望这会对您有所帮助
我想添加另一个解决方案,因为我在这里没有看到它。我的问题是 heroku 链接到了错误的 url(因为我一直在玩弄 url 名称)。编辑远程 url 解决了我的问题:
git remote set-url heroku <heroku-url-here>
我遇到过同样的问题。正如大家所说,我试图重置我的密钥,但它仍然没有奏效。因为是因为我重命名了应用程序。
所以我所做的是重置我的密钥并从控制台重命名应用程序。检查此问题以获取更多信息:Heroku push app problem
如此简单的解决方案,转到 c:/Users/user_name/.ssh/ 并删除所有 pub/private 密钥对,这样 heroku 将为您生成密钥。
我有一个类似的无法解决的 heroku ssh 错误。
作为一种解决方法,我使用了新的 heroku http-git 功能(“heroku”远程而不是 ssh 的 http 传输)。此处的详细信息:https://devcenter.heroku.com/articles/http-git
(简短版:如果您有一个项目已经设置了标准方式,请运行 heroku git:remote --http-init 将“heroku”远程更改为 http。)
如果您没有时间修复/解决 ssh 问题,这是一个很好的快速解决方法。
heroku keys:add
将帮助您创建一个。RSA
,则运行ssh-keygen -t rsa
,否则heroku keys:add
就足够了