I'm attempting to deploy my code to heroku with the following command line:
git push heroku master
but get the following error:
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
I have already uploaded my public SSH key, but it still comes up with this error.
You have to upload your public key to Heroku:
If you don't have a public key, Heroku will prompt you to add one automatically which works seamlessly. Just use:
To clear all your previous keys do :
To display all your existing keys do :
EDIT:
The above did not seem to work for me. I had messed around with the
HOME
environment variable and so SSH was searching for keys in the wrong directory.To ensure that SSH checks for the key in the correct directory do :
Which will display the following ( Sample ) lines
Permission denied (publickey).
From the above you could observe that ssh looks for the keys in the
/c/Wrong/Directory/.ssh
directory which is not where we have the public keys that we just added to heroku ( usingheroku keys:add ~/.ssh/id_rsa.pub
) ( Please note that in windows OS~
refers to theHOME
path which in win 7 / 8 isC:\Users\UserName
)To view your current home directory do :
echo $HOME
orecho %HOME%
( Windows )To set your
HOME
directory correctly ( by correctly I mean the parent directory of.ssh
directory, so that ssh could look for keys in the correct directory ) refer these links :SO Answer on how to set Unix environment variable permanently
SO Question regarding ssh looking for keys in the wrong directory and a solution for the same.
If you are a windows user the other solutions here probably won't solve your problem.
I use Windows 7 64-Bit + Git-1.7.7.1-preview20111027 and the solution was to copy my keys from
C:\users\user\.ssh
toC:\Program Files (x86)\Git\.ssh
. That's where this git client looks for the keys when pushing to heroku.I hope this helps.
Here is the link that explains how to manage your ssh keys : http://devcenter.heroku.com/articles/keys#adding_keys_to_heroku
Pushing was working for me and then stopped suddenly.
If the heroku api is experiencing downtime, you will get this error when you try to push.
Check:
https://status.heroku.com/
before freaking out too hard.
I was experiencing the same problem; following these steps should help:
.pub
files andknow_host
) in.ssh/ folder
At first make sure hidden files are visible in your Mac. If not do:
defaults write com.apple.Finder AppleShowAllFiles TRUE
killall Finder
Next steps:
Users/user_name/.ssh/
removed all the files.ssh-keygen -t dsa
heroku keys:add ~/.ssh/id_dsa.pub
N.B. I did it in Mac OSX 10.7.2 Lion. Though the procedure should be same in others too.