git push heroku master is asking for authentication
Contact me at LinkedIn  RailsZilla at Facebook  RailsZilla at twitter   google +1  Contact me at Xing  connect me at github

git push heroku master is asking for authentication

Posted in console, Start

In this post I show you how to fix the authentication problem with heroku.
If you want to deploy your branch to heroku using this command

1
$ git push heroku master

and git want an authentication like this

1
2
Username for 'https://git.heroku.com':
Password for 'https://git.heroku.com':

then the repository is not pushed, because heroku will not allow you to authenticate with username and password.

We will get an error like this:

1
2
3
4
#remote: ! WARNING:
#remote: ! Do not authenticate with username and password using git.
#remote: ! Run `heroku login` to update your credentials, then retry the git command.
#remote: ! See documentation for details: https://devcenter.heroku.com/articles/http-git#authentication

First we should validate our connection with the following command:

1
$ ssh -v git@heroku.com

Somewhere in end of the messages of this debugging output, we should see something like this

1
#Authenticated to heroku.com ([123.12.75.117]:22).

If you see something like this

1
#Permission denied (publickey).

Then we should try to generate ssh keys first.
Use this command

1
2
3
4
5
6
7
8
9
$ ssh-keygen -t rsa
#Generating public/private rsa key pair.
#Enter file in which to save the key (/Users/railszilla/.ssh/id_rsa):
#Enter passphrase (empty for no passphrase):
#Enter same passphrase again:
#Your identification has been saved in /Users/railszilla/.ssh/id_rsa.
#Your public key has been saved in /Users/railszilla/.ssh/id_rsa.pub.
#The key fingerprint is:
#a3:88:0a:22:74:f9:c6:e9:d5:49:d6:d1:04:e1:6c:3e railszilla@workstation.local

Then we add the keys to heroku with this command:

1
2
3
$ heroku keys:add
# Found existing public key: /Users/railszilla/.ssh/id_rsa.pub
# Uploading SSH public key /Users/railszilla/.ssh/id_rsa.pub... done

Now let’s have a look at our keys

1
2
3
$ heroku keys
# === info@railszilla.com Keys
# ssh-dss AAAAB8NzaC...DVj3R4Ww== railszilla@workstation.local

The final solution
We now have to use SSH Git transport

1
git config --global url.ssh://git@heroku.com/.insteadOf https://git.heroku.com/

HTTP URLs will still be written to .git folders but Git will rewrite, on the fly, all Heroku HTTP Git URLs to use SSH.

To remove this rewrite setting, run:

1
$ git config --global --remove-section url.ssh://git@heroku.com/

You an now use

1
$ git push heroku master

and deploy your application at heroku.
Have fun and never stop coding ;-)

Tags: , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

Please enter a secure code to see if you are a spammer ;-)

 

Copyright © 2011-2017  - RailsZilla – Ruby on Rails tutorials, tips and tricks All rights reserved. | Imprint | Privacy