2014-01-30 73 views
1

我已經有git設置併成功推送到Heroku大約6個月(在Mac上使用Github應用程序的mac)。Heroku權限被拒絕/無法連接到heroku api

昨天突然我再也不能推動變化的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. 

環視了一下,似乎這可能是我的關鍵問題之後。 我創建了一個新的密鑰,並把它添加到的Heroku這似乎工作:

$ ssh-keygen -t rsa 
Generating public/private rsa key pair. 
Enter file in which to save the key (/Users/kat/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/kat/.ssh/id_rsa. 
Your public key has been saved in /Users/kat/.ssh/id_rsa.pub. 

$ heroku keys:add 
Found existing public key: /Users/kat/.ssh/github_rsa.pub 
Uploading SSH public key /Users/kat/.ssh/github_rsa.pub... done 

但現在我得到一個不同的錯誤,當我嘗試推到Heroku的:

$ git push heroku master 
fatal: 'heroku' does not appear to be a git repository 
fatal: Could not read from remote repository. 

任何建議將是非常感謝,謝謝

+0

運行:git remote heroku show。它打印出什麼?它是否丟失?添加它:git remote add heroku <你的git repo>。然後再試一次。 – DiegoSalazar

回答

1

它看起來像heroku遙控器一路上迷路了。在你的shell中執行git remote -v,並檢查是否配置了推送的「heroku」分支。它應該看起來像這樣:

heroku [email protected]:myrepo.git (push)

如果沒有設置遠程分支,請執行heroku git:remote -a my-app-name並配置它。有關更多詳細信息,另請參閱this article

+0

工作 - 非常感謝你! – whitenk

0

我知道這是一個老問題,但我只是遇到了這個問題,不得不做很多的故障排除,以最終解決它。以爲我會發布我所做的,以防其他人面臨同樣的困難。

這就是我所做的解決mac上的問題。

卸載並重新安裝的Heroku

$ rm -rf ~/.heroku 
    $ sudo rm -rf /usr/local/heroku /usr/bin/heroku 

下載最新的Heroku CLI(原Heroku的列工具) https://devcenter.heroku.com/articles/heroku-command-line

登錄

$ heroku login 

您可能需要檢查你的ssh鍵現在可以。

$ ssh-keygen -t rsa 

接下來,運行以下命令以確保您的本地SSH密鑰添加到Heroku的。

$ heroku keys:add 

註銷並返回到Heroku。 (注意這不是標準的heroku登錄)。我不確定爲什麼這是不同的,但它對我有用。

$ heroku auth:logout 

    $ heroku auth:login 

確保Heroku remote git與項目關聯。在我來說,我不得不添加如下:

`$ heroku git:remote -a <my-app-name>` 

哪裏<my-app-name>是應用程序的實例已經在Heroku上的名字。如果您沒有登錄Heroku網站並設置新的應用程序。

然後我做了一個標準的git添加和提交。

`$ git add .` 

    `$ git commit -am "fixing heroku connection issue"` 

生成一個新的Heroku認證令牌。這似乎是關鍵的一步。

`$ heroku auth:token` 

這應該會返回由字母和數字組成的很長的auth-token

再次嘗試推,但如果提示使用所產生auth-token密碼:

$ git push heroku master 

    Username for 'https://git.heroku.com': <your-username> or leave blank 
    Password for 'https://git.heroku.com': <auth-token> 

如果一切工作應該建立和推動應用的Heroku。

其中一些步驟可能不是必需的,或者可能需要按不同的順序完成。如果第一次不工作,不要氣餒。爲了讓它工作,我不得不拍攝幾張照片。希望有所幫助!

相關問題