我正在尝试使用以下命令行将代码部署到heroku:
git push heroku master
但会出现以下错误:
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
我已经上传了我的公共SSH密钥,但仍然会出现此错误。
我正在尝试使用以下命令行将代码部署到heroku:
git push heroku master
但会出现以下错误:
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
我已经上传了我的公共SSH密钥,但仍然会出现此错误。
当前回答
听起来您的~/.ssh/authorized_keys文件设置不正确。验证:
它在正确的路径上。文件的权限为0600。~/.ssh的权限为0700。
其他回答
这个问题困扰了我几天。
这可能会有所帮助。
1) 看看你现在在Heroku有什么钥匙。
$ heroku keys
=== 1 key for joe@example.com
ssh-dss AAAAB8NzaC...DVj3R4Ww== joe@workstation.local
2) 构建~/.ssh/config文件:
$ sudo vim ~/.ssh/config
使用此信息编辑
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
当TortoiseGIT安装在我的机器上时,我遇到了这个问题。将环境变量GIT_SSH从
"c:\Program Files\TortoiseGit\bin\TortoisePlink.exe"
to
"c:\Program Files (x86)\Git\bin\ssh.exe"
使用ssh-keygen和keys完成本教程:add,它起作用了!
听起来您的~/.ssh/authorized_keys文件设置不正确。验证:
它在正确的路径上。文件的权限为0600。~/.ssh的权限为0700。
如果要使用“sudo”,例如:
sudo git clone git@heroku.com......... -o heroku
您还应该为root用户生成ssh密钥。
sudo su
cd /root/.ssh
ssh-keygen -t rsa
....
heroku keys:add id_rsa.pub
它会奏效的。
如果不使用root用户,请在用户目录中生成ssh密钥。
cd /home/user/.ssh
对不起,如果我的句子搞砸了。。。
要遵循的顺序
$ heroku login
$ ssh-keygen -t rsa
$ heroku keys:add
当执行第二条语句时,它会要求输入,只需按Enter(回车)三次,就会添加一个键。