Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add heroku key to git to work properly

Tags:

git

github

heroku

I am using windows7. I have created heroku APP using

heroku create loka-xxxx

It will create an app for me with git link.

[email protected]:loka-xxxx.git

but when i do.

git push heroku master

It gives me this error "Permission denied (publickey)".

Before heroku i had github installed on my window machine. So, this is key error. For this when i do

heroku keys

this show me a key.

I want to know how add this heroku key to git and how to tell git to use different keys to use at different operations(default & heroku).

like image 579
lokeshjain2008 Avatar asked Feb 14 '14 20:02

lokeshjain2008


People also ask

How does Heroku work with git?

Git is a powerful, distributed version control system that many developers use to manage and version source code. The Heroku platform uses Git as the primary means for deploying applications (there are other ways to transport your source code to Heroku, including via an API).

Why is Heroku not connecting to GitHub?

We are unable to access this connected repository on GitHub The authorization key is not valid, or the account used to connect to GitHub doesn't have access to the repository. Try disconnecting the repository above and then reconnect.


2 Answers

Here is the steps i followed to make heroku work with git on my windows machine. Step 1: create ssh rsa keys to use. 1.1 On windows to create ssh keys you need some additional tools from here.

Step 2: Generate ssh key using putty key-gen. name this key as id_rsa. Now you have to pair of id_rsa key(pub&ppk).

Step 3: Put these keys into your

c:\users\<user-name>\.ssh 

folder.

Step 4. Now go to the folder where your git is installed. like

C:\Program Files (x86)\Git

and try to create .ssh folder. Note: to create .ssh folder you need to run cmd as administrator and run mkdir .ssh.

Step 5. Now put your id_rsa key pair in this folder "C:\Program Files (x86)\Git\.ssh"

Step 6. open your cmd again. Goto your app folder and do initialize git again. here is the sequence of commands.

git init
git add .
git commit -m "This will be resolved now"
heroku keys:clear
heroku keys:add

git remote add heroku [email protected]:<your app>.git

Now you can do

git push heroku master. Hope i have covered all the steps for the windows user. for mac and unix user follow. Winfield

like image 153
lokeshjain2008 Avatar answered Oct 21 '22 22:10

lokeshjain2008


If you only have your git keys, you can add your current SSH public key to Heroku to allow pushing with whatever key is already configured on your local git install:

> heroku keys:add

... and then select id_rsa.pub or whichever key you are using already.

This will allow you to push to github using your existing key.

If you have the private key for the public key already on your Heroku account (listed via heroku keys), you can over-write the default private key in $HOME/.ssh/id_rsa with your Heroku private key.

like image 39
Winfield Avatar answered Oct 21 '22 21:10

Winfield