厌倦了我的 Rails 应用程序的 Heroku SSH 混乱
Posted
技术标签:
【中文标题】厌倦了我的 Rails 应用程序的 Heroku SSH 混乱【英文标题】:Tired of Heroku SSH mess for my rails application 【发布时间】:2014-06-30 03:57:12 【问题描述】:我不知道我做了什么,但对我来说现在真是一团糟。 我正在尝试将我的 rails 应用程序代码推送到 heroku
git push heroku master
这个错误出现了:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
好的,现在我将尝试创建一个新的 ssh 密钥来修复它
sudo ssh-keygen -t rsa
我按了三下回车,然后我的 ssh 密钥就创建好了。
但是现在当我对 heroku 说“请添加这个新密钥”时:
heroku keys:add
然后终端响应:
Found the following SSH public keys:
1) github_rsa.pub
2) id_rsa.pub
Which would you like to use with your Heroku account? 2
Uploading SSH public key /Users/demarox/.ssh/id_rsa.pub... failed
! This key is already in use by another account. Each account must have a unique key.
我不明白发生了什么,也许计算机不是我的堡垒。而且我没有使用 github_rsa.pub 因为它给了我更多的 heroku 错误,而且似乎 id_rsa.pub 是所有人都使用的 ssh 密钥,所以我不想弄乱它。如何修复?
编辑:好的,也许这会有所帮助。此时我想把电脑扔出窗外。
Demarox:saga_plast_app demarox$ sudo git push heroku master
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Demarox:saga_plast_app demarox$ sudo ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/var/root/.ssh/id_rsa):
/var/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /var/root/.ssh/id_rsa.
Your public key has been saved in /var/root/.ssh/id_rsa.pub.
The key fingerprint is:
f9:d0:45:80:4d:53:63:e5:36:38:60:80:ce:c8:1d:c9 root@Demarox.local
The key's randomart image is:
+--[ RSA 2048]----+
| . o.=*o=.. |
| E ...= + |
| . = . + + |
| o + o . o . |
| S . |
| o |
| . |
| |
| |
+-----------------+
Demarox:saga_plast_app demarox$ heroku keys:add
Found the following SSH public keys:
1) github_rsa.pub
2) id_rsa.pub
Which would you like to use with your Heroku account? 2
Uploading SSH public key /Users/demarox/.ssh/id_rsa.pub... failed
! This key is already in use by another account. Each account must have a unique key.
Demarox:saga_plast_app demarox$ heroku keys:clear
Removing all SSH keys... done
Demarox:saga_plast_app demarox$ heroku keys
You have no keys.
Demarox:saga_plast_app demarox$ heroku keys:add
Found the following SSH public keys:
1) github_rsa.pub
2) id_rsa.pub
Which would you like to use with your Heroku account? 2
Uploading SSH public key /Users/demarox/.ssh/id_rsa.pub... failed
! This key is already in use by another account. Each account must have a unique key.
【问题讨论】:
我认为您需要了解 SSH。首先,阅读本教程:support.suso.com/supki/SSH_Tutorial_for_Linux 然后,检查这个 *** 问题(我知道你没有使用多个 Heroku 帐户,但如果你使用 SSH 的多个 any 帐户,这个问题很有帮助): ***.com/questions/4663103/multiple-heroku-accounts 【参考方案1】:在生成密钥或执行 git push 时不应使用 sudo
。
使用 sudo 会导致它以 root 用户身份执行,您可以从它正在打印的消息中看到,这导致它将密钥保存到 /var/root 而不是您的主文件夹。同样,这将导致 git push 使用错误的 ssh 密钥。
【讨论】:
是的,这是另一个问题。如果我使用的是管理员帐户,如何摆脱这种情况? 停止在这些命令前加上 sudo 前缀,这将是一种复杂的方式。 唯一需要添加前缀的是 git add --all。我在 git 中重新启动了所有东西,sudo 的东西就消失了。【参考方案2】:sudo 不是问题。交易是我使用外国帐户登录以上传到另一个不同的帐户。因此,当我使用某个帐户再次登录然后我重新启动我的 SSH 密钥时,问题就解决了;工作。谢谢大家的支持,我爱你们。
【讨论】:
以上是关于厌倦了我的 Rails 应用程序的 Heroku SSH 混乱的主要内容,如果未能解决你的问题,请参考以下文章
Rails Heroku Cloudflare SSL 和 websockets