9

(Using Vista)I'm trying to clone an app from my GitHub Repository and push it into Heroku. Okay, so I've tried to create an SSH key so many times with this:

 `ssh-keygen -t rsa` 

It seems to go perfectly. I have it on my C:/Users/***/.ssh folder. I now try to clone an app i forked in GitHub. When I try to clone it on the rails_apps directory, I get a message saying

 Permission Denied(public key). 

I found a solution on the net saying that I should run this first:

`ssh-add` 

So I tried doing that. But it said that:

Could not open a connection to your authentication agent.

Then after some googling I find something about executing the ssh-agent. So I do this:

`ssh-agent bash`

and the command line changes from my rails_apps directory to this:

`bash3.1$>`

So I run:

`bash3.1$>ssh-add [path to .ssh folder]`

and it successfully adds the rsa private key(it doesn't work with id-rsa.pub). I have also pasted the newly generated public key to my GitHub account.

Now when I try to clone:

`bash3.1$>git clone git@github.com:username/myrepo.git`

It now successfully clones the repo I forked in GitHub. Now that I have the app in my local repo, I try to create a heroku app.

`bash3.1$>cd myrepo`  
`bash3.1$>heroku create myapp`

And this code runs successfully. Git remote added successfully. Now all I have to do is to push it.

`bash3.1$>git push heroku master`

BAM! I get the error message again.

Permission denied (public key)

I am so close into pushing my app to heroku. But it just won't work. Can you help me. What am I doing wrong here? Thanks! :D

KT.
  • 571
  • 3
  • 6
  • 19

4 Answers4

61

I had a similar problem. Running the following command fixed it for me:

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

Substitute "~/.ssh/id_rsa.pub" with your path to your id_rsa.pub file.

Graeme Collins
  • 611
  • 5
  • 3
  • Thanks, this was actually the correct answer. I knew I had changed my keys and was just looking for the command to update them :) – x10 Mar 20 '11 at 17:30
  • There's a nice little tutorial on it here http://ruby.railstutorial.org/chapters/beginning#sec:deploying – Neil Jul 06 '12 at 12:48
1

Note: your ticket on GitHub Support prompted the answer:

You need to give heroku your key. There should be a command to do it. If you can't find it, you'll have to contact their support.

For that, see Graeme Collins's answer (and also Heroku error: "Permission denied (public key)" ):

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

See Heroku devcenter for more on that process.
You can then see a list of all keys, including the key’s name, like this:

heroku keys

Note: that suppose you didn't use sudo to generate your keys, as " git clone heroku ssh permission denied " illustrates (where heroku keys:add doesn't work)


More information about your ssh keys in your other GitHub Support ticket.

debug1: Trying private key: /.ssh/identity
debug1: Trying private key: /.ssh/id_rsa
debug1: Trying private key: /.ssh/id_dsa

I'm not sure why it would be looking at /.ssh and not ~/.ssh then.
Try moving your keypair over to that path.


Shouldn't that be:

 git push origin master

? By default, a reference to the cloned repo is called 'origin', not 'heroku'

What does

git remote -v show

display?

It you want, you can reference the distant repo by the heroku name

git remote add heroku git@github.com:git_username/projectname.git
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks Von. I tried what you said changing heroku to origin. It didn't work as well. I tried the command you said. Now when I `git push heroku master` It says Everything up-to-date But the app is still not on heroku. I'm not sure what's going on. – KT. Dec 01 '09 at 09:41
1

The following line solved the problem for me.

heroku accounts:set youraccount
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Mingming
  • 2,189
  • 20
  • 21
0

You can login first in heroku providing Enail and Password and can follow the following steps to add a local git repository into a heroku application instance.

  1. Issue this command at the Git Bash $ ssh-keygen -t rsa (default location and with empty passphrase. You can alternatives too).
  2. Again issue at the bash $ heroku keys:add (It will automatically add the public key from the default location).
  3. Issu this at the bash to check keys. $ heroku keys .
  4. You can add the remote for you app name $ heroku git:remote -a app_name
  5. Now you can push the git repo to the heroku using this command $ heroku push origin master
FMQB
  • 653
  • 5
  • 12