Heroku:帐户无权访问应用程序

2024-02-23

我试图git pull heroku master,但我得到了

 !  Your account [email protected] /cdn-cgi/l/email-protection does not have access to app_name.
 !  
 !  SSH Key Fingerprint: 30:02:49:32...

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我已经做好了heroku login并已认证成功。我需要切换帐户,但不确定除此之外我还需要做什么heroku login.


尝试找到所有有用的答案here https://stackoverflow.com/questions/20586992/your-account-someoneelsegmail-com-does-not-have-access-to-app-name.

对我来说,我有两个不同的 heroku 帐户,每个帐户都与不同的 git 存储库关联。所以我必须告诉heroku为每个密钥使用特定的SSH密钥(显然,不仅仅是第一个可用的密钥,这似乎是默认行为)。对我有用的确切方法是按照以下步骤操作here https://stackoverflow.com/a/9149518/4294745进而here https://stackoverflow.com/a/13518981/4294745.

细节:

创建一个新的 rsa 密钥:指定您想要的任何电子邮件,并选择一个易于您记住并与特定 heroku 应用程序关联的名称。或者您可以将其命名为 /id_rsa_herokualt。

$ ssh-keygen -t rsa -C "youremail[at]domain.com" -f  ~/.ssh/id_rsa_myherokuapp

添加到您的机器:确保输入的文件名与您在上一步中指定的文件名完全相同。

$ ssh-add ~/.ssh/id_rsa_myherokuapp

添加到 Heroku:这假设您已经使用登录到herokuheroku login.

$ heroku keys:add ~/.ssh/id_rsa_myherokuapp.pub

将 heroku.com 的备用主机添加到 ~/.ssh/config 中。通过转到 Finder 并按 command + shift + g 并输入 ~/.ssh/ 找到此文件。在文本编辑器中打开配置文件,添加以下文本,然后保存:

Host heroku-alt
HostName heroku.com
IdentityFile ~/.ssh/id_rsa_myherokuapp

更新项目中的 .git/config 以使用主机别名。通过转到 Finder 并按 command + shift + g 并输入 ~/path/to/your/repository/.git 找到此文件。在文本编辑器中打开配置文件,添加以下文本,然后保存:

[remote "heroku"]
  url = git@heroku-alt:myherokuapp.git
  fetch = +refs/heads/*:refs/remotes/heroku/*

解释:通过在特定项目的 .git/config 文件远程中选择 heroku 和 heroku-alt,您可以管理哪些项目使用哪些凭证。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Heroku:帐户无权访问应用程序 的相关文章

随机推荐