17

I just bought a new computer and I am trying to clone my heroku project on it.

Here's what I've done so far. I didn't include the trace, but everything was saved in the right place, and the functions ran without errors.

>> sudo ssh-keygen
>> heroku keys:add
>> sudo git clone -o heroku git@heroku.com:myapp.git

Initialized empty Git repository in /Users/macuser/Sites/shwagr/shwagr/.git/
Permission denied (publickey).

Then I heard about doing it through ssh bash..

>ssh-agent bash
>ssh-add ~/.ssh

Permissions 0777 for '/Users/macuser/.ssh' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.

What? Ok Dad..

>>sudo chmod 700 ~/.ssh
>>ssh-agent bash
>>ssh-add ~/.ssh
Enter passphrase for /Users/macuser/.ssh: 
Bad passphrase, try again for /Users/macuser/.ssh: 
Bad passphrase, try again for /Users/macuser/.ssh: 
Bad passphrase, try again for /Users/macuser/.ssh: 
Bad passphrase, try again for /Users/macuser/.ssh: 
Bad passphrase, try again for /Users/macuser/.ssh: 
Bad passphrase, try again for /Users/macuser/.ssh:

Not sure what the password here is, but it sure wasn't me who set this one. If I simply press return/enter, it exits out, but that doesn't give me the impression it worked. And consequentially, it still doesn't allow me to clone the repository.

Any ideas?

UPDATE I went into my ~/.ssh file and performed ssh-keygen -t rsa and i made a new key called love. Then I heroku keys:add love.pub successfully.

Then I went to git clone..

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

Initialized empty Git repository in /Users/macuser/Sites/shwagr/shwagr/.git/
Permission denied (publickey).

UPDATE 2

I deleted ~/.ssh, and recreated it without sudo. Then I removed all my keys I had created today off of heroku , and restarted the process.

Same error.

Update 3

>>heroku keys

  No Keys for this computer.

>>sudo heroku keys

  No Keys for this computer

>>heroku keys:add

>>heroku keys

ssh-rsa AAAA...J67lw== macuser@Mac-Users-MacBook-Pro.local

Compared these keys to my keys : They are identical. :D

Permission Denied.

Attempt 4

heroku keys:clear rm -rf ~/.ssh mkdir ~/.ssh cd ~/.ssh ssh-keygen -t rsa heroku keys:add cd /Users/macuser/Sites/ sudo git clone -o heroku git@heroku.com:shwagr.git

Failed.

fatal: The remote end hung up unexpectedly

Huge Update

Just found out that git repo is actually empty. And it's just a symbolic link ( when you attach a real domain to it it still uses the old one as the real repo ). So when I pulled one of Heroku's default names like smooth-buttery-back-52.git , it pulled and worked, and was actually my repository.

Trip
  • 26,756
  • 46
  • 158
  • 277
  • >UPDATE 2<: So you used `heroku keys:clear` or howd you go about it? – prodigitalson Aug 28 '10 at 15:05
  • I didn't want to do that because there are keys to users involved in the project on that. I just removed the ones pertaining to this computer. – Trip Aug 28 '10 at 15:06
  • @trip: so you did `heroku keys:remove youruser@yourhost`? Whats the ouput of `heroku keys` AND `sudo heroku keys`? – prodigitalson Aug 28 '10 at 15:07
  • The outputs for both are identical. the first two are for two other computers, and the last one is the one i put up after i removed the other keys. I did not `sudo heroku keys:add` anything. – Trip Aug 28 '10 at 15:13
  • 1
    ok do `heroku keys:remove your_user@your_host` to remove the current key for the host machine youre on now. then do `heroku keys` to verify. then do `heroku keys:add` again to re-add it. then verify again with `heroku keys` - comparing the key it shows with your `~/.ssh/id_rsa.pub`. – prodigitalson Aug 28 '10 at 15:38
  • @prodigatalson They are identical keys. – Trip Aug 28 '10 at 15:48
  • @trip: and they are for the exact same user@host? In that case try your clone again. – prodigitalson Aug 28 '10 at 15:53
  • Yep, identical. Clone returns Permission Denied. – Trip Aug 28 '10 at 16:06
  • 1
    did you do a `rm -rf /Users/macuser/Sites/shwagr/shwagr/.git/` with `sudo` if necessary? Also your clone command looked like so: `git clone git@heroku.com:mysite.git -o heroku`? – prodigitalson Aug 28 '10 at 16:21
  • Yah, sudo wasn't necessary. It's gone. Did a git clone, `Initialized empty Git repository in /Users/macuser/Sites/shwagr/.git/ Permission denied (publickey). fatal: The remote end hung up unexpectedly` – Trip Aug 28 '10 at 16:31
  • 1
    Tell me, do you have keys generated other than your rsa? I seem to recall someone having an issue where it was using their dsa key by default (you can set the default to rsa in your `.ssh/config`) als you might want to not specifically name the keys anything other than id_TYPE.pub, otherwise youll have to do some config settings for that too. – prodigitalson Aug 28 '10 at 18:02
  • Thanks for all your help btw. :D I tried completely rm -rf'ing the ~/.ssh all together, and recreated it. By default, there is no .ssh/config. Right now I don't have one. Maybe that's the problem? Also I tried uploading a key that was explicitly id_rsa.pub and one that was custom named, both seperately and each independently returned a permission denied. – Trip Aug 28 '10 at 19:04
  • I was just thinking..I sudo installed `git`. Would that have effected it? – Trip Aug 28 '10 at 19:30
  • @trip: well you would almost have to sudo to install git if you put it in the system for all users (ie. /usr/local, or your package manager's file subsystem - /opt/local in macports for example) but that shouldnt make a difference. I think the bottomline is there is a discrepency between the key youve allowed and the key youre transmitting, but after everythign we've tried i dont know whay that would be the case at this point. – prodigitalson Aug 28 '10 at 20:25
  • 1
    I just though of something... try moving your `~/.heroku` dir out of the way and setting it up again... i dont think there is anything in there that would foul it up but maybe give that a shot. Also if you have `~/.gitconfig` make sure there is nothing conflicting in there. – prodigitalson Aug 28 '10 at 20:29
  • 1
    Uh yah, it turns out that there is nothing in that git repo, and that my keys do in fact work. I had made a name for the app, and the repo wasn't actually being held on that name, it was held on the default name it came on. I'm retarded. Thank so much prodigitalson. Bask in the karma I'm going to give you. – Trip Aug 28 '10 at 20:56
  • OMG, haha... Its always the silly things. I had a similar brain fart with a svn repo i set up once. Took me two hours of trying different things before i realized i was using the .com domain where the site lived instead of the .net domain where the repo was. At that point i just wanted to shoot myself in the face. I feel your pain :-) – prodigitalson Aug 28 '10 at 21:01

6 Answers6

11

I followed the steps provided by heroku and it worked. Once you have generated ssh keys (it does not matter what you call the files), just do the following:

> heroku login
> heroku keys:add

The first statement prompts you for your heroku userid/password. Once you are authenticated, running the second command picks all your public keys and pushes it out to heroku.com. After that you can run git clone and it will work like a charm!

Tabrez
  • 3,424
  • 3
  • 27
  • 33
6
>> sudo ssh-keygen

NO. Drop the sudo. That will create keys for the root user, not your user. Well unless of course for some strange reason you want to use root. But then you need to prefix all related commands that are going to use this key with sudo.

prodigitalson
  • 60,050
  • 10
  • 100
  • 114
  • back up your ssh config: `mv ~/.ssh ~/ssh.bak` (use sudo if necessary since you may have inadvertently locked yourself out). then `ssh-keygen` again. if you have anything special set up in your `ssh.back/config` copy it back over to the newly generated one. – prodigitalson Aug 28 '10 at 14:53
  • 2
    since you just bought a new computer. restore it and dont use sudo, ever, unless you really really have to. use rvm and homebrew and stay local :) you are officially in permissions hell. – Jed Schneider Aug 28 '10 at 14:54
  • Id second what Jed says though i dont think you should abandon sudo, you should learn what it means and the implications and then use it when necessary. Also id recommend macports over homebrew, but its really a personal preference thing. – prodigitalson Aug 28 '10 at 14:56
  • Thanks man.. you saved me some hair pulling.. I rebuilt my Mac and used sudo to generate my keys, which caused Heroku to puke. deleted all my keys from Heroku, created a new key using ssh-keygen, heroku keys:add and my git push worked like a champ.. – Don Apr 09 '11 at 03:49
3

https://devcenter.heroku.com/articles/keys#adding_keys_to_heroku It worked with me :

$ heroku keys:add

Ngô Văn Thao
  • 3,671
  • 1
  • 20
  • 24
3

If you already done

heroku keys:add

and still getting error, then please try

ssh-add
Hardik Hardiya
  • 837
  • 6
  • 14
2

this is a plugin for heroku to manage your account. https://github.com/ddollar/heroku-accounts

angelokh
  • 9,426
  • 9
  • 69
  • 139
1

you made a key for your sudo account, but not for your user account and you didn't sudo heroku keys:add so it uploaded the local user key not the sudo key, i'm guessing. Why would you want your local app in your home directory to have sudo permissions anyway? I would probably x the sudo and just do it as your user following this tutorial: http://docs.heroku.com/keys

Jed Schneider
  • 14,085
  • 4
  • 35
  • 46
  • it won't let me >> open love failed: Permission denied. Saving the key failed: love. – Trip Aug 28 '10 at 14:53
  • @Trip: see my comment on my answer for how to fix... you've borked this at this point and need to nuke it from space... it's the only way to be sure. – prodigitalson Aug 28 '10 at 15:00
  • i did and updated my asnwer. same problem. Is there a permissions purgatory? – Trip Aug 28 '10 at 15:04