git Heroku“权限被拒绝(公钥)致命:无法从远程存储库读取”问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17626944/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Heroku 'Permission denied (publickey) fatal: Could not read from remote repository' woes
提问by thebradbain
I've searched around for many hours on end looking to a solution to my seemingly easy-to-fix problem. It's not that my search turned up nothing, it's that my search turned up so many different solutions -none of which have worked.
我已经搜索了好几个小时,寻找解决我看似容易解决的问题的方法。并不是我的搜索一无所获,而是我的搜索发现了许多不同的解决方案——但没有一个奏效。
Anyways, I am simply unable to push, pull, or fetch from my Heroku repository from my Mac. Every attempt gives me (as if it's mocking me) the following error:
无论如何,我根本无法从 Mac 的 Heroku 存储库中推送、拉取或获取。每次尝试都会给我(好像在嘲笑我)以下错误:
'Permission denied (publickey). fatal: Could not read from remote repository.'
'权限被拒绝(公钥)。致命:无法从远程存储库读取。
I've tried (and re-tried) to fix it in many different ways. As I've said, I've spent a good chunk of the last two days searching around for an answer. Here are some of the things I've tried:
我已经尝试(并重新尝试)以多种不同的方式修复它。正如我所说,过去两天我花了很多时间四处寻找答案。以下是我尝试过的一些事情:
- heroku keys:clear followed by heroku keys:add
- Regenerating an ssh key on my own with 'ssh-keygen -t rsa'
- Clearing out my .ssh directory, followed by heroku keys:clear, followed by generating an ssh key
- Deleting my app on heroku and recreating one (fortunately not much was on there)
- heroku 键:清除后跟 heroku 键:添加
- 使用“ssh-keygen -t rsa”自行重新生成 ssh 密钥
- 清除我的 .ssh 目录,然后是 heroku 密钥:清除,然后是生成 ssh 密钥
- 在 heroku 上删除我的应用程序并重新创建一个(幸运的是那里没有太多)
I can fetch from my GitHub repository fine, so I know it's not network connectivity (pinging heroku also works).
我可以很好地从我的 GitHub 存储库中获取,所以我知道这不是网络连接(ping heroku 也可以)。
As a makeshift solution (that I hope doesn't turn into a permanent one), I've logged in to my Ubuntu Amazon AWS ec2 instance. Pulling and pushing to and from Heroku works perfectly. For this reason, I still feel as if the problem lies with the ssh key on my Mac. Both keys show up under my Heroku account. Does the email address at the end of the key matter?
作为一种临时解决方案(我希望不会变成永久解决方案),我已登录到我的 Ubuntu Amazon AWS ec2 实例。从 Heroku 拉和推非常有效。出于这个原因,我仍然觉得问题出在我的 Mac 上的 ssh 密钥上。两个键都显示在我的 Heroku 帐户下。密钥末尾的电子邮件地址重要吗?
EDIT: I can push and pull from GitHub fine (I'm not using ssh, however), so why not Heroku?
编辑:我可以很好地从 GitHub 推和拉(但是我没有使用 ssh),那么为什么不使用 Heroku?
At this point I'm willing to try anything. Thanks!
在这一点上,我愿意尝试任何事情。谢谢!
采纳答案by thebradbain
I just thought I'd share that I found the answer to my own question.
我只是想我会分享我找到了我自己问题的答案。
Writing out my problem made it even more clear to me, and I further investigated into where I thought my problem lay: the ssh key
写出我的问题让我更加清楚,我进一步调查了我认为我的问题所在:ssh 密钥
Turns out I was right. The issue wasn't with the key itself, but rather that I had not added it to my local Mac's list of known ssh keys. So even though my Heroku account had the correct key uploaded, my Mac could not authenticate with it because it could not find that key on my computer. The solution?
原来我是对的。问题不在于密钥本身,而在于我没有将它添加到本地 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
I would like to give credit to https://help.github.com/articles/error-permission-denied-publickeyfor being a good reference.
我想感谢https://help.github.com/articles/error-permission-denied-publickey作为一个很好的参考。
回答by Kris Hollenbeck
I know this has already been answered. But I would like to add my solution as it may helpful for others in the future..
我知道这已经得到了回答。但我想添加我的解决方案,因为它可能在未来对其他人有帮助。
A common key error is: Permission denied (publickey)
. You can fix this by using keys:add
to notify Heroku of your new key.
一个常见的关键错误是:Permission denied (publickey)
. 您可以通过使用keys:add
通知 Heroku 新密钥来解决此问题。
In short follow these steps: https://devcenter.heroku.com/articles/keys
简而言之,请按照以下步骤操作: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:
heroku keys:add
回答by Bryan Myers
I had the exact same error (on windows 7) and the cause was different. I solved it in a different way so I thought I'd add the cause and solution here for others.
我有完全相同的错误(在 Windows 7 上),原因不同。我以不同的方式解决了它,所以我想我会在这里为其他人添加原因和解决方案。
Even though the error seemed to point to heroku really the error was saying "Heroku can't get to the git repository"
. I swore I had the same keys on all the servers because I created it and uploaded it to one after the other at the same time.
即使错误似乎指向 heroku 确实是错误在说"Heroku can't get to the git repository"
。我发誓我在所有服务器上都有相同的密钥,因为我创建了它并同时将其上传到另一个。
After spending almost a day on this I realized that because git was only showing me the fingerprint and not the actual key. I couldn't verify that it's key matched the one on my HD or heroku. I looked in the known hosts file and guess what... it shows the keys for each server and I was able to clearly see that the git and heroku public keys did not match.
在花了将近一天的时间之后,我意识到这是因为 git 只向我展示了指纹而不是实际的密钥。我无法验证它的密钥是否与我的 HD 或 Heroku 上的密钥匹配。我查看了已知的主机文件并猜猜是什么......它显示了每个服务器的密钥,我能够清楚地看到 git 和 heroku 公钥不匹配。
1) I deleted all the files in my key folder, the key from github using their website, and the key from heroku using git bash and the command heroku keys:clear
1)我删除了密钥文件夹中的所有文件,使用他们的网站从 github 中删除了密钥,使用 git bash 和命令删除了来自 heroku 的密钥 heroku keys:clear
2) Followed github's instructions hereto generate a new key pair and upload the public key to git
2)按照github的说明在这里生成一个新的密钥对并将公钥上传到git
3) using git bash-
heroku keys:add
to upload the same key to heroku.
3)使用git bash-
heroku keys:add
将相同的密钥上传到heroku。
Now git push heroku master
works.
现在git push heroku master
工作。
what a nightmare, hope this helped somebody.
真是一场噩梦,希望这对某人有所帮助。
Bryan
布莱恩
回答by sjking
The problem I was having is that I was only using https for my GitHub account. I needed to make sure that my GitHub account was setup for ssh access and that GitHub and heroku were both using the same public keys. These are the steps I took:
我遇到的问题是我的 GitHub 帐户只使用 https。我需要确保我的 GitHub 帐户设置为 ssh 访问,并且 GitHub 和 heroku 都使用相同的公钥。这些是我采取的步骤:
Navigate to the ~/.ssh directory and delete the id_rsa and id_rsa.pub if they are there. I started with new keys, though it might not be necessary.
$ cd ~/.ssh $ rm id_rsa id_rsa.pub
- Follow the steps on gitHub to generate ssh keys
Login to heroku, create a new site and add your public keys:
$ heroku login ... $ heroku create $ heroku keys:add $ git push heroku master
导航到 ~/.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 master
回答by oqx
i had the same case on linux ubuntu and just fixed it, it seems that OS was confused between the /root/.ssh/ and home/user/.ssh/ dir, what i did was:
我在 linux ubuntu 上有同样的情况并刚刚修复它,似乎操作系统在 /root/.ssh/ 和 home/user/.ssh/ 目录之间混淆,我所做的是:
- removed all keys from root and home/user .shh directory.
- generated a new keymake sure to pay attention to the path of creation (/home/you/.ssh/id_rsa) or (/root/.ssh/id_rsa)
- check heroku keys
heroku keys
- if keys in there clear
heroku keys:clear
heroku keys:add
now in here if heroku couldn't find a key and asked to generate one right no, and this mean you have the same issue as mine, do the add command like thisheroku keys:add /root/.ssh/id_rsa.pub
the path that you'll add will be the one that you got in step 2.- try
git push heroku master
now
- 从 root 和 home/user .shh 目录中删除了所有密钥。
- 生成新的key一定要注意创建路径(/home/you/.ssh/id_rsa)或者(/root/.ssh/id_rsa)
- 检查heroku键
heroku keys
- 如果钥匙在那里清除
heroku keys:clear
heroku keys:add
现在在这里,如果 heroku 找不到密钥并要求生成一个正确的不,这意味着您和我有同样的问题,请执行这样的添加命令heroku keys:add /root/.ssh/id_rsa.pub
,您将添加的路径将是您获得的路径在步骤 2 中。git push heroku master
现在试试
回答by Ivan Rave
My way on Windows 8
我在 Windows 8 上的方式
Add a directory with ssh-keygen to the system PATH variable, usually C:\Program Files (x86)\Git\bin
Open CMD, go to C:\Users\Me\
Generate SSH key
ssh-keygen -t rsa
Enter file in which to save the key (//.ssh/id_rsa): .ssh/id_rsa (change a default incorrect path to .ssh/somegoodname_rsa)
Add the key to Heroku
heroku keys:add
Select a created key from a list
Go to your app directory, write some beautiful code
Init a git repo
git init
git add .
git commit -m 'chore(release): v0.0.1
Create Heroku application
heroku create
Deploy your app
git push heroku master
Open your app
heroku open
在系统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
从列表中选择创建的密钥
转到您的应用程序目录,编写一些漂亮的代码
初始化一个 git 仓库
git init
git add .
git commit -m 'chore(release): v0.0.1
创建 Heroku 应用程序
heroku create
部署您的应用
git push heroku master
打开你的应用
heroku open
回答by user3484361
Had a similar issue, and tried lots of things. Ultimately what worked for me, was to have Gnu on Windows installed (https://github.com/bmatzelle/gow/releases) , and ensure that it was using the ssh tool inside that directory and not the one with Git. Once installed test with (ensure if its in your environment PATH that it preceds Git\bin)
有一个类似的问题,并尝试了很多东西。最终对我有用的是在 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
I used putty and pageant as described here:http://rubyonrailswin.wordpress.com/2010/03/08/getting-git-to-work-on-heroku-on-windows-using-putty-plink-pageant/
我使用了腻子和选美,如下所述:http: //rubyonrailswin.wordpress.com/2010/03/08/getting-git-to-work-on-heroku-on-windows-using-putty-plink-pageant/
Once the keys had been sent to heroku (heroku keys:add c:\Users\Person.ssh\id_rsa.pub), use
一旦密钥被发送到 heroku (heroku keys:add c:\Users\Person.ssh\id_rsa.pub),使用
ssh -v <username>@heroku.com
and ensure that your stack is showing use of Putty - ie a working stack:
并确保您的堆栈显示使用 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
One that was running previously and failed:
之前运行但失败的一个:
C:\Git\htest2>ssh -v <username>@[email protected]
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).
回答by nabin
you need to create a new ssh key by typing the following - ssh-keygen -t rsa
您需要通过键入以下内容来创建一个新的 ssh 密钥 - ssh-keygen -t rsa
Then you need to add: - heroku keys:add
然后你需要添加: - heroku keys:add
Then if you type - heroku open
然后如果你输入 - heroku open
The problem has been solved.
问题已经解决。
It worked for me anyway, you could give it a try...
无论如何它对我有用,你可以尝试一下......
回答by rocLv
I got the same error, and because I have 4 ssh-keys, so I tried follow:
我遇到了同样的错误,因为我有 4 个 ssh 密钥,所以我尝试遵循:
ssh-keygen -t rsa
heroku keys:add
then, four options show:
然后,显示四个选项:
1) github_rsa.pub
2) id_boot2docker.pub
3) id_rsa.pub
4) sshkey.pub
I choose 3), the newest one
我选择3),最新的
Then, I fix the error.
然后,我修复了错误。
回答by ytv
I'd like to add another solution since I didn't see it here. My problem was that heroku was linking to the wrong url (since I kept playing around with url names). Editing the remote url solved my problem:
我想添加另一个解决方案,因为我在这里没有看到它。我的问题是 heroku 链接到错误的 url(因为我一直在玩 url 名称)。编辑远程 url 解决了我的问题:
git remote set-url heroku <heroku-url-here>