Heroku error: "Permission denied (public key)"

32,597

Solution 1

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

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

Solution 2

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

Solution 3

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

Solution 4

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

Solution 5

if you dont have ssh key yet then try generating it using below command :

1. ssh-keygen -t rsa -C "[email protected]"
2. ssh-add

For getting rid of heroku permission denied (public key) add your keys to heroku using:

3. heroku keys:add <path_to_your_ssh>
    OR
 heroku keys:add

For getting rid of Github permission denied (public key) add your keys to Github using:

4. ssh-add <path_to_your_ssh> 
     OR
  ssh-add
Share:
32,597
jdahlgren
Author by

jdahlgren

Updated on July 16, 2020

Comments

  • jdahlgren
    jdahlgren almost 4 years

    I keep getting this error. I am using Mac. I generated a key and added it to heroku using

    heroku config:add key="ssh-rsa [email protected]"

    But this doesn't work. I keep getting the same error. Short of reinstalling ssh-keygen, what can I do about this?