Permission denied (publickey) when deploying herok

2019-01-02 19:20发布

I'm attempting to deploy my code to heroku with the following command line:

git push heroku master

but get the following error:

Permission denied (publickey).
fatal: The remote end hung up unexpectedly

I have already uploaded my public SSH key, but it still comes up with this error.

30条回答
像晚风撩人
2楼-- · 2019-01-02 19:26

The problem I faced was on Windows and invariably whenever I run the "heroku keys:add" it selected the github keys. So here are the steps I followed to resolve the issue

  1. went to the .ssh directory under "Document and Settings" folder and deleted the git hub keys
  2. run the command heroku keys:add

The above command asked me to generate a new keys and following was the output Could not find an existing public key. Would you like to generate one? [Yn] Y Generating new SSH public key. Uploading SSH public key C:/Documents and Settings/Admin/.ssh/id_rsa.pub... done ! The 'heroku' gem has been deprecated and replaced with the Heroku Toolbelt, download and install from https://toolbelt.heroku.com.

  1. rerun the command heroku keys:add

The above command will not give the following output Found existing public key: C:/Documents and Settings/Admin/.ssh/id_rsa.pub Uploading SSH public key C:/Documents and Settings/Admin/.ssh/id_rsa.pub... done

  1. Now use the git push heroku master

for me using the above steps solved the issue and was able to deploy the application on the cloud.

查看更多
妖精总统
3楼-- · 2019-01-02 19:28

I have this issue as well. I am using Mac OSX. The way I fixed that was to login as admin

sudo su

password

查看更多
残风、尘缘若梦
4楼-- · 2019-01-02 19:29

This was the solution for me:

ssh-add ~/.ssh/my_heroku_key_rsa
查看更多
刘海飞了
5楼-- · 2019-01-02 19:29

If you've already uploaded the key then try to remove the key and then re-upload it with a new key.

 heroku keys:remove //removes the existing key
 ssh-keygen -t rsa //generates a new key in ~/.ssh folder
 heroku keys:add    //uploads the new key, if no arguments r passed then the key generated                              
                    //in default directroy i.e., ~/.ssh/id_rsa is uploaded
 git push heroku

this should work.

查看更多
泪湿衣
6楼-- · 2019-01-02 19:29

I had this problem when TortoiseGIT was installed on my machine. After changing the environment variable GIT_SSH from

"c:\Program Files\TortoiseGit\bin\TortoisePlink.exe"

to

"c:\Program Files (x86)\Git\bin\ssh.exe"

and following this tutorial with ssh-keygen and keys:add, it works!

查看更多
其实,你不懂
7楼-- · 2019-01-02 19:32

One single command works:

heroku keys:add

It will make one if it doesn't exist.

查看更多
登录 后发表回答