Error while deploying application in heroku - ruby-on-rails

I am getting below error while creating app and deploying in heroku using below command
sudo git push heroku master
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I tried all the possible scenarios
creating new ssh key , giving admin rights to folder, deleting git remote for heroku and adding it again etc
Steps followed by me:
1) git init
2) git add .
3) git commit -m "Initial Commit"
4) heroku login
5) heroku create
6) sudo git push heroku master
Usually when we create new heroku project using "heroku create" it will create new project and that heroku URL is set as heroku GIT remote URL, but that also not happening everytime i am doing it manually. May be this also due to that same issue i guess...
Below is my detailed error
ponvino#ponvino-desktop:~/RubyWorkspace/prod/theScholarsPage$ sudo mv ~/.ssh/ /.ssh_backup
ponvino#ponvino-desktop:~/RubyWorkspace/prod/theScholarsPage$ heroku keys:add
Could not find an existing public key.
Would you like to generate one? [Yn] y
Generating new SSH public key.
Uploading SSH public key /home/ponvino/.ssh/id_rsa.pub... done
ponvino#ponvino-desktop:~/RubyWorkspace/prod/theScholarsPage$ git push heroku master
The authenticity of host 'heroku.com (50.19.85.156)' can't be established.
RSA key fingerprint is 8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1f:c8:60:ad.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'heroku.com,50.19.85.156' (RSA) to the list of known hosts.
Agent admitted failure to sign using the key.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
Please help me
Thanks in Advance,

Check that your ssh key is loaded:
ssh-add -l
If not:
ssh-add ~/.ssh/your_private_key
Try again to push to heroku

You should generate pair of keys and add your public key to your heroku account.
More info: https://devcenter.heroku.com/articles/keys
ssh-keygen -t rsa
and then:
heroku keys:add
should be enough.

If nothing works even after trying the above solutions. do this
$ mv ~/.ssh/ ~/.ssh_backup
$ heroku keys:add
$ git push heroku master

Almost same problem was asked and answered in the link below.
Try it

Related

Heroku: Permission denied (publickey). fatal: Could not read from remote repository when doing git push

I've spent the day reviewing all the existing solutions suggested on Stackoverflow and elsewhere, and tried them without success, and I'm still stuck with this.
The "heroku keys:add" solution doesn't work for me, so please don't link me back to that one.
I'm on MacOSX Lion. Thanks
Heroku no longer needs to use the git protocol & Public/Private encryption keys, instead you can use the following command to use your Heroku API key
heroku login
This command creates (or updates) a ~/.netrc file with your Heroku API key.
Now, any Heroku remote repository can be pushed to via the https protocol, rather than the git (ssh) protocol.
Check the address of your Heroku repository for your project with:
git remote -v
If your git remote address for Heroku starts with https://git.heroku.com/... then you are good to push. If the remote address starts with git then you need to update the remote address for Heroku
git remote set-url heroku https://git.heroku.com/...
Check the Heroku dashboard Settings tab for your app for the full Git URL for that app
If you have already git initialized and heroku toolbet is completely installed , enter this command $ git remote -v it will initialize heroku git and you can push to it.
Whenever you run the command $ git remote -v , will create a git repo in app_name/.git/logs//refs/remote/heroku , first check whether your git been initialized for heroku or not, even I had the same problem and I've corrected.

Can't access my Heroku repo even though I've added my key

I'm trying to clone a current project from Heroku. I was having permission access issues so I removed existing keys, and added my current key:
$ heroku keys:add
Found an SSH public key at /home/martyn/.ssh/id_rsa.pub
Would you like to upload it to Heroku? [Yn] Y
Uploading SSH public key /home/martyn/.ssh/id_rsa.pub... done
$ heroku keys
=== martynbissett#yahoo.co.uk Keys
ssh-rsa AAAAB3NzaC...5VRkk6UVBT martyn#martyn-Lenovo-B590
$ heroku git:clone -a young-lowlands-8336
Cloning from app 'young-lowlands-8336'...
Cloning into 'young-lowlands-8336'...
Agent admitted failure to sign using the key.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I've check the site is live, and it is. From my Heroku control panel I can see that this project is active too. Why am I still being denied?
This is the response I got back from Heroku, and it seems to work now:
It looks like your local SSH is using a different key than the default one.
Could you try resetting your keys identities to the default with the following command:
ssh-add -D

Can't push to Heroku using git push heroku master (Could not read from remote repository)

I am trying to push my rails app to Heroku. When I attempt to push to heroku:
git push heroku master
I get the following error:
! Your account abc#abc.com does not have access to APPNAME
! SSH Key Fingerprint: 8b:ac:.......
fatal: Could not read from remote repository
Please make sure you have the correct access rights and the repository exists.
When I type:
heroku keys
I can see my ssh-rsa key.
What I have tried:
Clear all SSH keys (both heroku and gitHub). Create a new SSH key for GitHub and upload this same SSH key to both Heroku and Github
Opened GitBash and
ssh-add
ssh-add -l
To add and verify only one key:
Login to heroku website and verify only one key at SSH key field
I can push to GitHub fine but not to Heroku. Can anyone please help?
1) Firstly do the heroku keys:add and then try or copy your ssh key and paste it, on the account settings of heroku.
2) Secondly checking that ur this ssh key not be accessed by another heroku app ?

Git push heroku master error?

I have successfully created using heroku create but when i push from git it gives me error as below:-
C:\Sites\boot>git push heroku master
! Your account snehp92#gmail.com does not have access to protected-thicket-253
8.
!
! SSH Key Fingerprint: 6e:d8:39:da:45:ad:b5:b2:e5:36:2e:14:0e:92:b5:8e
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
You need to add your ssh key to heroku. To add your keys run the following command
heroku keys:add
If you don't have a key then generate a new key with
ssh-keygen -t rsa
and then add the ssh key to heroku
I would recommend getting the latest version of Heroku Toolbelt, and then adding the repository again:
$ heroku login
Enter your Heroku credentials.
Email: adam#example.com
Password:
Could not find an existing public key.
Would you like to generate one? [Yn]
Generating new SSH public key.
Uploading ssh public key /Users/adam/.ssh/id_rsa.pub
git remote -v
git remove heroku master
heroku git:remote -a protected-thicket-253

Is heroku key set correctly?

I'm trying to deploy a project to heroku. I'm working on win7.
$ git push heroku master
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
$ heroku keys
Enter your Heroku credentials.
Email: MYREALEMAIL
Password (typing will be hidden):
=== MYREALEMAIL Keys
ssh-rsa AAAAB3NzaC...ol1Ukh0Q== your_email#youremail.com
$ heroku keys:remove your_email#youremail.com
Removing your_email#youremail.com SSH key... done
dnir#BCMAM27 /f/EasyPHP-12.1/www/phantomjs123 (master)
$ heroku keys
You have no keys.
$ heroku keys:add f:/.ssh/id_rsa.pub
Uploading SSH public key f:/.ssh/id_rsa.pub... done
$ heroku keys
=== MYREALEMAIL Keys
ssh-rsa AAAAB3NzaC...ol1Ukh0Q== your_email#youremail.com
$ git push heroku master
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I am concerned that the last line should actually say:
ssh-rsa ****3NzaC...ol1Uk****== MYACTUALEMAIL
Am I correct in this? If so how do I fix this?
check out this article on how to set up ssh keys on heroku.
to remove the bad key
heroku keys:remove your_email#youremail.com
then verify that you have a ssh key
cat ~/.ssh/id_rsa.pub
if not create one
ssh-keygen -t rsa -C "your_email#youremail.com"
then upload the key to heroku
heroku keys:add
Looks like an SSH issue. I think you'll need to generate a new SSH key based on your email.
If you cat ~/.ssh/id_rsa.pub you'll see "your_email#youremail.com" at the end. you need to generate a new one with your email (or hostname).

Resources