Heroku error: "Permission denied (public key)"

Try heroku keys:add <path-to-your-public-key>.

For example, heroku keys:add ~/.ssh/id_rsa.pub


the solution above did not work for me as I did not have any keys generated in my ~/.ssh folder.

My solution was to simply type heroku keys:add

The output in terminal was:

Could not find an existing public key.
Would you like to generate one? [Yn] y
Generating new SSH public key.
Uploading SSH public key /home/funkdified/.ssh/id_rsa.pub... done

See: https://devcenter.heroku.com/articles/keys


i faced the same issue . Writing my experience so it helps someone else .

I tried to follow the instructions that were detialed on the official website -Getting Started with Your Facebook App on Heroku

Even though it is quite detialed especially the video it is quite annoying to note that they do not mention having to set up SSH keys . Either it is set by default ( i dont know ) or you get the error mentioned by the question poster .

So i did the following :

1 . opened up the git shell

2 . typed the following in

C:\Users\blue\Documents\GitHub> 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

3 . Subsequent to this i was able to getcheckout my repository

C:\Users\blue\Documents\GitHub> heroku login
Enter your Heroku credentials.
Email: [email protected]
Password (typing will be hidden):
Authentication successful.
C:\Users\blue\Documents\GitHub> git clone [email protected]:sxxxd-plains-8530.gi
t
Cloning into 'sxxxd-plains-8530'...
Warning: Permanently added 'heroku.com,50.19.85.154' (RSA) to the list of known
hosts.
remote: Counting objects: 180, done.
remote: Compressing objects: 100% (112/112), done.
remote: Total 180 (delta 82), reused 132 (delta 62)
Receiving objects:  81% (146/180), 76.00 KiB | 62 KiB/s
Receiving objects: 100% (180/180), 137.91 KiB | 62 KiB/s, done.
Resolving deltas: 100% (82/82), done.
C:\Users\blue\Documents\GitHub>

Please dont downvote my answer . Even though i dont add any new value to what is already posted but i hope my experiences will help someone who is new to using git & heruko . Hence i added screen shots .

  • My 2 cents

Copy the files in your .ssh path ex:

/c/Users/<yourusername>/.ssh/<files>

to the git .ssh folder.

/c/Program Files/Git/.ssh/<paste files here>

If the .ssh folder doesn't exist in the Git directory simply create it then paste your files.

For some reason windows require that a .ssh path be in the user directory as well as the Git directory. ON default this is not added so you simply have to create it yourself.

After adding the files to Git's directory simply run the following command again:

git push heroku master