Permission denied (publickey) when deploying herok

2019-01-02 19:20发布

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.

30条回答
伤终究还是伤i
2楼-- · 2019-01-02 19:21

This problem was messing with me for a few days.

This might help.

1) Find out what keys you have in Heroku now.

$ heroku keys
=== 1 key for joe@example.com
ssh-dss AAAAB8NzaC...DVj3R4Ww== joe@workstation.local

2) Build a ~/.ssh/config file:

$ sudo vim ~/.ssh/config

Edit with this info

Host heroku.com
Hostname heroku.com 
Port 22 
IdentitiesOnly yes 
IdentityFile ~/.ssh/ssh-dss # location and name of your private key
TCPKeepAlive yes 
User joe@workstation.local
查看更多
浪荡孟婆
3楼-- · 2019-01-02 19:21

Check your .ssh config for heroku. Go to the .ssh folder and open the config file

cd ~/.ssh
subl config

The 'subl' is for Sublime Text, but you can use whatever editor you wish. Look for the line "IdentityFile" and make sure it has the non public key listed:

IdentityFile "/Users/ircmullaney/.ssh/my_ssh"

not

IdentityFile "/Users/ircmullaney/.ssh/my_ssh.pub"

That did it for me. I'm not sure why mine had the public version in the config file, but it did and it was throwing the error:

Permissions 0644 for '/Users/ircmullaney/.ssh/my_ssh.pub' are too open.
查看更多
裙下三千臣
4楼-- · 2019-01-02 19:21

Try repairing permissions in Disk Utility (Mac OS X). Helped me

查看更多
余欢
5楼-- · 2019-01-02 19:23

I killed myself for 3 days trying every possible combination to try to get this to work -- I finally tried making a DSA key instead and it worked.

Try DSA instead of RSA if it's not working for you.

(I'm using Ubuntu 11.10, ruby 1.8.7, heroku 2.15.1)

查看更多
何处买醉
6楼-- · 2019-01-02 19:25

If you want to use "sudo", example:

sudo git clone git@heroku.com......... -o heroku

you should also generate ssh key for your root user.

sudo su
cd /root/.ssh  
ssh-keygen -t rsa
....
heroku keys:add id_rsa.pub

and it'll work.

if you don't use root user, generate ssh key in your user directory instead.

cd /home/user/.ssh

Sorry if my sentences messed up...

查看更多
旧人旧事旧时光
7楼-- · 2019-01-02 19:26

Sequence to follow

$ heroku login
$ ssh-keygen -t rsa
$ heroku keys:add

When executing second statement it would ask for input, just press Enter(return) three times and a key will be added.

查看更多
登录 后发表回答