2014-05-12 70 views
0

我不知道我做了什麼,但對我來說它現在是一個真正的混亂。 我試着去推我的Rails應用程序的代碼的Heroku與厭倦了Heroku爲我的導軌應用程序SSH混亂

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 [email protected] 
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. 
+0

我認爲你需要一個關於SSH的入門書。首先,閱讀本教程:http://support.suso.com/supki/SSH_Tutorial_for_Linux然後,檢查此stackoverflow問題(我知道你沒有使用多個Heroku帳戶,但如果你使用多個**任何**帳戶與SSH,這個問題是有幫助的):http://stackoverflow.com/questions/4663103/multiple-heroku-accounts – richsinn

回答

0

當您生成密鑰或執行git push時,您不應該使用sudo

使用sudo會導致它執行root用戶,並且您可以從它正在打印的消息中看到,這導致它將密鑰保存到/ var/root而不是您的主文件夾。同樣,這會導致git push使用錯誤的ssh密鑰。

+0

是的,這是另一個問題。如果我在管理員帳戶中,該怎麼擺脫? – user3623994

+0

停止在sudo前面添加這些命令,這將是一個複雜因素。 –

+0

唯一需要加前綴的是git add --all。我重新啓動了所有的混帳和sudo的東西消滅了。 – user3623994

0

sudo的東西不是問題。該交易是我用外國賬戶登錄上傳到另一個不同的賬戶。所以當我用某個賬戶重新登錄然後重新啓動我的SSH密鑰時,問題就解決了;工作。感謝支持人員,我愛你。