856

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.

NikiC
  • 100,734
  • 37
  • 191
  • 225
vich
  • 11,836
  • 13
  • 49
  • 66
  • did sebarmeli's solution work for you? I'm not using an rsa key named "id_rsa.pub" and just had enter "heroku keys:add ~/.ssh/.pub" – Michael Merchant Oct 05 '11 at 00:40
  • 6
    I had this problem almost a year ago and the proposed solution at the time didn't exactly work for me, but I figured it out somehow (at this point I don't remember what I did exactly). Sebarmeli answered a while after I no longer needed assistance, although it seems his answer is quite popular among those that experienced a similar problem. If it makes people happy, I'll choose his answer as the correct one. – vich Oct 05 '11 at 01:35
  • 3
    The following line solved the problem for me. heroku accounts:set youraccount – Mingming Jan 14 '12 at 16:47
  • Seems some heroku services are down today-- be sure to check their site for issues if you're debugging this! – Philip Guin Sep 04 '13 at 17:04
  • I had the same problem, all I needed to do is `heroku login` then write email and password and try again. – Alejandro Veintimilla Jun 06 '14 at 23:20

34 Answers34

1484

You have to upload your public key to Heroku:

heroku keys:add ~/.ssh/id_rsa.pub

If you don't have a public key, Heroku will prompt you to add one automatically which works seamlessly. Just use:

heroku keys:add

To clear all your previous keys do :

heroku keys:clear

To display all your existing keys do :

heroku keys

EDIT:

The above did not seem to work for me. I had messed around with the HOME environment variable and so SSH was searching for keys in the wrong directory.

To ensure that SSH checks for the key in the correct directory do :

ssh -vT git@heroku.com

Which will display the following ( Sample ) lines

OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Connecting to heroku.com [50.19.85.156] port 22.
debug1: Connection established.
debug1: identity file /c/Wrong/Directory/.ssh/identity type -1
debug1: identity file /c/Wrong/Directory/.ssh/id_rsa type -1
debug1: identity file /c/Wrong/Directory/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version Twisted
debug1: no match: Twisted
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Host 'heroku.com' is known and matches the RSA host key.
debug1: Found key in /c/Wrong/Directory/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /c/Wrong/Directory/.ssh/identity
debug1: Trying private key: /c/Wrong/Directory/.ssh/id_rsa
debug1: Trying private key: /c/Wrong/Directory/.ssh/id_dsa
debug1: No more authentication methods to try.

Permission denied (publickey).

From the above you could observe that ssh looks for the keys in the /c/Wrong/Directory/.ssh directory which is not where we have the public keys that we just added to heroku ( using heroku keys:add ~/.ssh/id_rsa.pub ) ( Please note that in windows OS ~ refers to the HOME path which in win 7 / 8 is C:\Users\UserName )

To view your current home directory do : echo $HOME or echo %HOME% ( Windows )

To set your HOME directory correctly ( by correctly I mean the parent directory of .ssh directory, so that ssh could look for keys in the correct directory ) refer these links :

  1. SO Answer on how to set Unix environment variable permanently

  2. SO Question regarding ssh looking for keys in the wrong directory and a solution for the same.

Community
  • 1
  • 1
sebarmeli
  • 17,949
  • 7
  • 35
  • 40
  • 31
    Didn't work for me. I had to revoke my old key and then let heroku app generate and upload a new one for me. See the link on how to do this provided by Lithium. – borisdiakur Oct 26 '11 at 22:49
  • 9
    just a note to people saying it didn't work. you need to make sure you have an ssh public key already made. http://help.github.com/mac-set-up-git/ for more info on doing so with mac. – Ryan Dec 28 '11 at 00:08
  • This worked for me: although I'd uploaded my pub key to github, I had omitted to upload it to Heroku as well. – Steve Pitchers Mar 09 '12 at 14:44
  • 93
    if you don't have a public key, heroku will prompt you to add one automatically which works seamlessly. Just use: `heroku keys:add` – vansan Jul 09 '12 at 15:55
  • 13
    Also try `ssh-keygen -t rsa -C "your_email@youremail.com"` if still having the error, to create another file.pub and use that one in the recommended command in this answer – Tom Roggero Oct 23 '12 at 04:01
  • what if I don't want to revoke my old key and add a new one anyway? do I need to have the very same key on other computers? – Mihai Bujanca Apr 10 '13 at 17:30
  • `heroku keys:add` will find existing SSH key and will upload it. Still, `Permission denied (publickey)` will happen again. – Alvaro Lourenço May 01 '13 at 19:59
  • 3
    You may have to create/re-create a key before adding to heroku. http://www.whatibroke.com/?p=284 has worked for me for Windows 7. – Khalid Saifullah May 24 '13 at 13:48
  • 1
    `ssh-add /Users/YourName/.ssh/your_heroku_key` was the thing I initially forgot. – LeEnno Nov 03 '13 at 15:40
  • 1
    on windows, you also need to copy your key to your git/.ssh dir. see http://www.gmarwaha.com/blog/2011/05/18/heroku-trouble-with-windows-and-ssh-keys/ After trying EVERYTHING else that is what worked for me. – Joseph Eames Nov 14 '13 at 09:25
  • awesome! for windows users use git bash – Jorge Guerola Feb 23 '14 at 19:22
  • Works great when you have created keys. If you have multiple keys then add the one you need. –  Apr 25 '14 at 20:10
  • Heroku now has beta support for HTTP Git: https://devcenter.heroku.com/articles/http-git. See my answer below for details. – ryanbrainard Nov 09 '14 at 06:25
  • I think there is a bug with the heroku gem. It won't let me use a public key other than what is in the default location. – Abe Petrillo Mar 27 '15 at 14:01
  • Running heroku keys:add fixed my issue. However I had issues generating keys so I had to do fresh install of git for windows then i can it from a new cmd with administrator permissions. – Jpepper Oct 17 '16 at 17:45
148

I had the same issue, the steps below worked for me,

->heroku login

abc@gmail.com & password

->cd C:\Users\yourusername\.ssh    (OR for cygwin shell ->cd ~/.ssh)

->ssh-keygen -t rsa -f id_rsa

if asks any passphrase don't use blank, fill with a passphrase,but not forget it.

After generating the key you need to add it, like so

$ ssh-add

and it to heroku

->heroku keys:add "id_rsa.pub"

change directory to workspace, than

->git clone git@heroku.com:stark-dawn-1234.git -o heroku

use passphrase that you set above.


Actually i also remove files below, but not sure that they are imp,

C:\Users\yourusername.heroku\credientals and C:\Users\yourusername.ssh\known_hosts

Gaurav Agarwal
  • 18,754
  • 29
  • 105
  • 166
Onur Turhan
  • 1,237
  • 1
  • 13
  • 20
  • 21
    This solved it for me. I think the reason was, I had a 'github_rsa' file from `Github for Windows`, but no id_rsa file. – msiemens Jul 04 '12 at 11:40
  • Didn't work with Openssl installer. I had to install CopSSH to get the ssh-keygen.exe program. – djangofan Jun 14 '13 at 00:54
  • On Windows 7, I had to do this on `git bash` command prompt in order to run ssh-keygen. thanks. – Rots Jun 27 '13 at 09:47
  • This worked for me and seems to be the best solution. The better question is why I have to repeat this every other day – Paul Renton Jul 25 '13 at 01:43
  • 3
    This worked for me. If you're using Git Bash on Windows, the key MUST be named id_rsa.pub or it won't work, even if you upload something else to Heroku. – Kiv Aug 01 '13 at 19:46
  • Using Cygwin you should cd to your [Cygwin home directory] `~/.ssh` instead of `C:\Users\yourusername\.ssh` – Jeff Axelrod Aug 15 '13 at 18:47
  • Using ubuntu 14.04 and I was having problem with the **heroku git:clone -a myapp**...so I've tryed this **git clone git@heroku.com:myapp.git -o heroku** and this have solved my **permision denied publickey** problem. Thank you for this great tip! – hailton Nov 20 '14 at 05:48
  • Similarly as noted in a comment above, if you are using Git Bash on Windows it expects the id_rsa.pub to exist with id_rsa in ~/.ssh/. This is odd because in most shells you don't need the public key there. – Jason R Dec 23 '14 at 20:31
  • This fixed it for me, as I have multiple keys, it was offering up the wrong key. `ssh-add /path/to/my/key` – Rob Jul 09 '15 at 12:46
  • Just doing ssh-add fixed it for me – gabrielfreiberg Feb 24 '16 at 02:42
92

This problem was messing with me for a few days.

This might help.

1) Find out what keys you have in Heroku now.

$ heroku keys
=== 1 key for joe@example.com
ssh-dss AAAAB8NzaC...DVj3R4Ww== joe@workstation.local

2) Build a ~/.ssh/config file:

$ sudo vim ~/.ssh/config

Edit with this info

Host heroku.com
Hostname heroku.com 
Port 22 
IdentitiesOnly yes 
IdentityFile ~/.ssh/ssh-dss # location and name of your private key
TCPKeepAlive yes 
User joe@workstation.local
Aniket Tiwari
  • 3,561
  • 4
  • 21
  • 61
jkpham
  • 431
  • 4
  • 2
  • 3
    This worked for me as well, after nothing else did! However there should be a line break before `User` in that last line. Also, it complained about the `#` comment, so I just removed it. – Erik J Aug 07 '12 at 21:32
  • 2
    Make sure that the "IdentityFile" has the non public file (like above), not the public one. For some reason mine had the public version and it was throwing an error saying the permissions for the file were incorrect. – Kevin K Sep 26 '12 at 13:31
  • Adding this `host` info to my config file solved the problem for me. I created a heroku rsa key and the default permissions on heroku.pub threw an error when I tried to `git push`. I had to `chmod 600 heroku.pub` and then when I pushed it worked. – Dylan Valade Oct 12 '12 at 02:53
  • 1
    `IdentityFile ~/.ssh/ssh-dss` is the path to the **private** key. You want to enter your **private** key here, not your **public** key. – HairOfTheDog Apr 24 '13 at 21:43
  • Thank you everyone. It worked for me, once used private key (i.e. the one with out the pub extension). – Yosep Kim Oct 04 '13 at 20:21
  • 1
    This answer is what put me over the top. I am running windows 7 64 bit. There are a number of other steps that helped such as: ssh-keygen -t rsa -f id_rsa then deleting any heroku keys and adding the one just created: heroku keys:clear heroku keys:add C:\Users\username\.ssh\id_rsa.pub and then slightly modifying the above file to IdentityFile C:/Users/windows_username/.ssh/id_rsa – Paul Oct 18 '13 at 02:16
  • I tried countless approaches to this online and yours is the only one that worked. It really bothers me that I still don't fully understand exactly what the issue was, but thanks for posting this. – Zach Conn Dec 11 '13 at 00:55
  • The Heroku documention presumes that you have never used ssh keys. In reality ssh keys are used for lots of things. Just two lines in ~/.ssh/config did it for me. `Host heroku.com` `IdentityFile ~/.ssh/YOURSSHPRIVATEKEYFILE` – niknah Sep 21 '14 at 00:23
61

Here is the link that explains how to manage your ssh keys: https://devcenter.heroku.com/articles/keys#adding-keys-to-heroku

geisterfurz007
  • 5,292
  • 5
  • 33
  • 54
Lithium
  • 1,132
  • 11
  • 10
  • 2
    Heroku never prompted me to add one. So I had to do the ssh-keygen first. This helped. Thanks! – Kal Jan 04 '13 at 22:26
  • This one worked for me. Generated a new key, in my case overwrite the old one, then choose id_rsa.pub to use with heroku. Thanks – jfoutch Sep 13 '13 at 22:49
36

I had the same problem cause i had no public keys, so i did:

heroku keys:clear
heroku keys:add

That will generate a public key and then it works well

Stefan Manastirliu
  • 3,704
  • 3
  • 24
  • 18
  • 1
    Still getting the error. i try different things, solve it, then get the same problem the next week... I wonder why Heroku is like this. – JGallardo Nov 09 '13 at 07:46
31

If you are a windows user the other solutions here probably won't solve your problem.

I use Windows 7 64-Bit + Git-1.7.7.1-preview20111027 and the solution was to copy my keys from C:\users\user\.ssh to C:\Program Files (x86)\Git\.ssh. That's where this git client looks for the keys when pushing to heroku.

I hope this helps.

Christian Specht
  • 35,843
  • 15
  • 128
  • 182
Leo
  • 578
  • 9
  • 15
  • 2
    For me it was c:\msysgit\.ssh. I just created a directory junction to the .ssh folder in my personal folder. – Colin Bowern Nov 29 '11 at 02:33
  • Same problem here, but why I don't know. Each time I added keys it displayed that used the keys from my User folder, same with this fix but it worked. – Haris Krajina Apr 09 '12 at 11:09
  • 12
    DON'T DO THAT! This works because HOME is empty, and it defaults to current exe dir. If someone manages to logon as Guest, he can get your private key. Set HOME in Advanced User Settings to %HOME_DRIVE%%HOMEPATH%, (or C:\Users\ on Win7) and copy .ssh dir there. – dmajkic May 23 '12 at 07:43
  • Further to @dmajkic, on Win7 see this [Git for Windows Tip](http://danlimerick.wordpress.com/2011/07/11/git-for-windows-tip-setting-home-and-the-startup-directory/) for setting the `%HOME%` environment variable to `%USERPROFILE%`. – Steve Eynon Mar 31 '14 at 21:10
29

This was the solution for me:

ssh-add ~/.ssh/my_heroku_key_rsa
Gabor
  • 476
  • 5
  • 4
15

To share my experience :

Git (my own install) was looking for the key named 'id_rsa'.

So I tried to rename my keys to 'id_rsa' and 'id_rsa.pub' and it worked.

Btw, I'm sure there is an other way to do it but I didn't look deeper yet.

Maxence
  • 13,148
  • 4
  • 29
  • 28
  • 3
    Worked for me (Windows 7 64bit). I have GitHub for Windows installed, and it names the keys GitHub_rsa. Is there a way to specify which key Git should use? – Spongeboy Apr 09 '13 at 13:13
10

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.

Pablo Claus
  • 5,886
  • 3
  • 29
  • 38
7

I killed myself for 3 days trying every possible combination to try to get this to work -- I finally tried making a DSA key instead and it worked.

Try DSA instead of RSA if it's not working for you.

(I'm using Ubuntu 11.10, ruby 1.8.7, heroku 2.15.1)

Sauce McBoss
  • 6,567
  • 3
  • 20
  • 22
  • 1
    I talked with Heroku support, and they suggested this as a temporary solution. It worked for me, but I'm sure it's not the answer for every case. – Sauce McBoss Feb 07 '12 at 19:07
  • 3
    Not sure why this answer deserved a down vote... It solved the problem for me, and it suggests an answer to the problem. – Sauce McBoss Feb 27 '12 at 03:38
  • I had the opposite problem... even though the Heroku dev docs say you can use a DSA key (ssh-dss), I kept getting the 'Permission denied' message until I switched to an RSA key – brandonjp Mar 11 '12 at 07:48
  • worked for me. Toggling between dsa and rsa seems to work if you change your keys after heroku create and before git push. – Pramod Jul 22 '12 at 16:56
  • and how do I create a DSA key and add it to heroku? – coiso Mar 14 '14 at 14:13
6

On Windows 7,64 bit,the above solution (Onur Turhan's) worked for me with slight changes as below

C:\Users\MyName > heroku login

Enter email/password

C:\Users\MyName >ssh-keygen -t rsa -f id_rsa

This generated two files(id_rsa and id_rsa.pub) in my c:\Users\MyName directory (Not in .ssh directory)

heroku keys:add id_rsa.pub
git clone git@heroku.com:some-heiku-xxxx.git -o heroku

I guess adding the correct "id_rsa.pub" file is the most important.After generating the public key using keygen just verify that you are adding correct key by looking at the time-stamp when it was created.

Hrushikesh
  • 411
  • 5
  • 10
5

One single command works:

heroku keys:add

It will make one if it doesn't exist.

Travis Reeder
  • 38,611
  • 12
  • 87
  • 87
  • Downvote, this does not answer in context with the error. I removed existing, created new, and added the keys and still getting the problem. your suggestion of `heroku keys:add` is not a complete answer. – JGallardo Nov 09 '13 at 07:51
5

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!

eckes
  • 64,417
  • 29
  • 168
  • 201
zooli
  • 91
  • 2
  • 2
4

Pushing was working for me and then stopped suddenly.

If the heroku api is experiencing downtime, you will get this error when you try to push.

Check:

https://status.heroku.com/

before freaking out too hard.

Tronathan
  • 6,473
  • 5
  • 22
  • 24
3

Sequence to follow

$ heroku login
$ ssh-keygen -t rsa
$ heroku keys:add

When executing second statement it would ask for input, just press Enter(return) three times and a key will be added.

Saurabh Rana
  • 3,350
  • 2
  • 19
  • 22
2

For all those who tried everything mentioned above on Windows 7 and still it didn't work, here is what I've done: - open GitBash.exe from the Git directory C:\Program Files (x86)\Git\ (don't open a command prompt, this won't work). - add the following as mentioned above, but you have to delete the #

Host heroku.com
Hostname heroku.com 
Port 22 
IdentitiesOnly yes 
IdentityFile ~/.ssh/ssh-dss
TCPKeepAlive yes 
User joe@workstation.local

now run git push heroku master and it should work.

Community
  • 1
  • 1
Aymen Mouelhi
  • 2,384
  • 2
  • 18
  • 16
  • Upvoting this as well. Spent 6 hours with yesterday and don't feel like this is knowledge I care about at all. I can push to github through powershell and command prompt, but only Git Bash works for me for heroku. Now it works every time. I also wind up doing heroku login before git push heroku master. May not be necessary, but for now, it's superstition that keeps me doing it. What nightmare – JMDenver Feb 17 '15 at 19:21
2

The above given answer DOES work, but found out I needed to do some extra steps before it worked.

  1. I removed all id_rsa* files and generated a new SSH using this guide.
  2. Then, I destroyed the heroku app. Removed the ~/.heroku/credentials file.
  3. 'heroku create' command (and since the credentials file is removed, it will prompt you for your email/password.
  4. FINALLY type 'heroku keys:add' and it will upload the default ~/.ssh/id_rsa.pub file.
  5. It works! Well.... YMMV but I really do hope this can be some help as I struggled the whole day trying to figure this out! Haha
KoalaD
  • 357
  • 1
  • 4
  • 12
1

I had to do:

$ ssh-keygen -t rsa  
$ heroku keys:add  

Then it worked:

$ git push heroku master  
ericj
  • 2,138
  • 27
  • 44
1

Check your .ssh config for heroku. Go to the .ssh folder and open the config file

cd ~/.ssh
subl config

The 'subl' is for Sublime Text, but you can use whatever editor you wish. Look for the line "IdentityFile" and make sure it has the non public key listed:

IdentityFile "/Users/ircmullaney/.ssh/my_ssh"

not

IdentityFile "/Users/ircmullaney/.ssh/my_ssh.pub"

That did it for me. I'm not sure why mine had the public version in the config file, but it did and it was throwing the error:

Permissions 0644 for '/Users/ircmullaney/.ssh/my_ssh.pub' are too open.
Kevin K
  • 2,191
  • 2
  • 28
  • 41
1

I was still having problems after trying all of these ideas. This was my problem:

My remote heroku repository was funked. I refreshed it as follows:

git remote -v

Then remove the heroku one that is wrong:

git remote rm heroku

Then add the new one

git remote add heroku git@heroku.com:sitename.git

You can get the sitename from your Heroku settings page for your app. Good Luck!

thatdankent
  • 950
  • 8
  • 15
1

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.

Ashok
  • 11
  • 1
1

I was experiencing the same problem; following these steps should help:

  1. First, log in: heroku login
  2. Clear all keys: heroku keys:clear
  3. Delete all files in local folder ( all .pub files and know_host) in .ssh/ folder
  4. Log in again : heroku login - u will prompt with no key, so follow the onscreen instructions.
Jules
  • 14,200
  • 13
  • 56
  • 101
Novpiar Effendi
  • 307
  • 3
  • 4
1

It sounds like your ~/.ssh/authorized_keys file is not set up correctly. Verify that:

  • It is in the correct path.
  • The permissions of the file are 0600.
  • The permissions of ~/.ssh are 0700.
cdhowie
  • 158,093
  • 24
  • 286
  • 300
  • I'm fairly new at this stuff so sorry if this is going to sound dumb, but my public SSH key file is just a bunch of characters (standard key gen) with no other information. I acquired this SSH file when I setup git on my computer. I assumed this would be the same public SSH key that I would use to deploy my heroku code. Or does heroku have its own public SSH key that I need to generate? – vich Nov 24 '10 at 18:18
  • 1
    Yes, you can reuse your public SSH key for many different hosts. I am not sure exactly how Heroku works, but I can see that my answer doesn't really apply in this case. You might verify that your key was accepted by their web interface. If everything still checks out, try contacting their support team. – cdhowie Nov 24 '10 at 18:21
  • Thanks for the advice! I have contacted heroku support. I will update once I have an answer. – vich Nov 24 '10 at 18:28
  • Ok. I'm interested to hear what the problem is too. :) – cdhowie Nov 24 '10 at 18:29
  • 1
    So, the issue was with naming the public SSH key file. When I had originally created the file, I also renamed it, which caused issues in deploying as git would not connect properly and thus made heroku deployment a failure as well. To solve the problem, I generated a new public SSH key and added that to github prior to attempting again. It now connects! Thanks for your help! – vich Nov 24 '10 at 19:55
0

If you want to use "sudo", example:

sudo git clone git@heroku.com......... -o heroku

you should also generate ssh key for your root user.

sudo su
cd /root/.ssh  
ssh-keygen -t rsa
....
heroku keys:add id_rsa.pub

and it'll work.

if you don't use root user, generate ssh key in your user directory instead.

cd /home/user/.ssh

Sorry if my sentences messed up...

Kiddo
  • 1,167
  • 1
  • 12
  • 23
0

Try repairing permissions in Disk Utility (Mac OS X). Helped me

Ildar
  • 343
  • 1
  • 10
0

At first make sure hidden files are visible in your Mac. If not do:

  • Open terminal and type in defaults write com.apple.Finder AppleShowAllFiles TRUE
  • killall Finder

Next steps:

  • Going to Users/user_name/.ssh/ removed all the files.
  • Opening terminal type in ssh-keygen -t dsa
  • Then heroku keys:add ~/.ssh/id_dsa.pub

N.B. I did it in Mac OSX 10.7.2 Lion. Though the procedure should be same in others too.

Munim
  • 2,626
  • 1
  • 19
  • 28
0

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

sudo su

password

Community
  • 1
  • 1
Jake Lin
  • 11,146
  • 6
  • 29
  • 40
0

Solution of dmajkic help me at last:

For Windows users it may means: git client coudn’t find your keys. Check keys in c:\Users\UserName.ssh\ and! environment variable HOME=c:\Users\UserName\

Grigory Kislin
  • 16,647
  • 10
  • 125
  • 197
0

Here is what worked for me. The heroku site is not being added to your known hosts. Go to window-other- show view-git-git repositories. From there clone the repository. Once you clone it, delete the repository that was just created and then import it from the file menu. Do this since when you clone the repository, it does not add it to the explorer view. Now you should have the git repository and the explorer view.

0

when pushing using

git push heroku production:master 

your public key under home directory ~/.ssh/id_rsa is used

To fix this

you should login as a different user may be root

sudo su 

then start fresh by issuing the following commands

heroku keys:clear //removes existing keys
ssh-keygen -t rsa //generates a new key in ~/.ssh folder (set a password)
heroku keys:add   //uploads the new key, ~/.ssh/id_rsa is uploaded                      
git push heroku production:master
HimalayanCoder
  • 9,630
  • 6
  • 59
  • 60
0

If the other answers didn't worked for you. Try this!

Sometimes all you need is to push again. It happen to me today due to slow internet connection(when you are downloading or using p2p).

Please see screenshot below:

enter image description here

Adrian Enriquez
  • 8,175
  • 7
  • 45
  • 64
0

Instead of dealing with SSH keys, you can also try Heroku's new beta HTTP Git support. It just uses your API token and runs on port 443, so no SSH keys or port 22 to mess with.

To use HTTP Git, first make sure Toolbelt is updated and that your credentials are current:

$ heroku update
$ heroku login

(this is important because Heroku HTTP Git authenticates in a slightly different way than the rest of Toolbelt)

During the beta, you get HTTP by passing the --http-git flag to the relevant heroku apps:create, heroku git:clone and heroku git:remote commands. To create a new app and have it be configured with a HTTP Git remote, run this:

$ heroku apps:create --http-git

To change an existing app from SSH to HTTP Git, simply run this command from the app’s directory on your machine:

$ heroku git:remote --http-git
Git remote heroku updated

Check out the Dev Center documentation for details on how set up HTTP Git for Heroku.

ryanbrainard
  • 5,918
  • 35
  • 41
0

I reinstalled heroku toolbelt and it worked.

Alexis
  • 23,545
  • 19
  • 104
  • 143
0

I would just to like to add that the directory is not necessarily C:\Users\[username]\.ssh. It is the directory in which you created your public key in.

For instance my home directory in Windows was changed to C:\[username]. Your home directory in a .ssh sub-folder is the best and most likely place you may have created your keys. You can check your home directory in Windows with the command:

    echo %HOMEPATH%
Nicholas
  • 78
  • 7