为什么 Heroku 会给出权限被拒绝的错误?
当
$ git clone -v [email protected]:testabcde.git Cloning into testabcde...
Heroku 返回
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
当
$ heroku keys
返回
=== 1 key for [email protected]
ssh-rsa AAAAB3NzaC...lXLyj9YQ== [email protected]
立即
$ ssh -v [email protected] -T
OpenSSH_5.2p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to heroku.com [50.19.85.154] port 22.
debug1: Connection established.
debug1: identity file /Users/ohho/.ssh/identity type -1
debug1: identity file /Users/ohho/.ssh/id_rsa type 1
debug1: identity file /Users/ohho/.ssh/id_dsa type 2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-5pgsql1
debug1: match: OpenSSH_5.1p1 Debian-5pgsql1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'heroku.com' is known and matches the RSA host key.
debug1: Found key in /Users/ohho/.ssh/known_hosts:5
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/ohho/.ssh/identity
debug1: Offering public key: /Users/ohho/.ssh/id_rsa
debug1: Remote: Forced command: /home/git/bin/git_proxy [email protected]
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: Offering public key: /Users/ohho/.ssh/id_dsa
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
如何修复 Permission returned (publickey)
错误?
更新(文件权限信息):
drwxr-xr-x 11 ohho staff 374 Sep 16 09:37 .
drwxr-xr-x+ 50 ohho staff 1700 Sep 15 10:34 ..
-rw------- 1 ohho staff 1743 Sep 16 09:37 github_rsa
-rw-r--r-- 1 ohho staff 390 Sep 16 09:37 github_rsa.pub
-rw-r--r-- 1 ohho staff 390 Sep 9 09:47 github_rsa.pub_bak-github
-rw------- 1 ohho staff 1743 Sep 9 09:47 github_rsa_bak-github
-rw------- 1 ohho staff 736 Dec 2 2010 id_dsa
-rw-r--r-- 1 ohho staff 606 Dec 2 2010 id_dsa.pub
-rw------- 1 ohho staff 1743 Jan 28 2011 id_rsa
-rw-r--r-- 1 ohho staff 399 Jan 28 2011 id_rsa.pub
-rw-r--r--@ 1 ohho staff 10752 Sep 16 11:47 known_hosts
When
$ git clone -v [email protected]:testabcde.git Cloning into testabcde...
Heroku returns
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
When
$ heroku keys
returns
=== 1 key for [email protected]
ssh-rsa AAAAB3NzaC...lXLyj9YQ== [email protected]
now
$ ssh -v [email protected] -T
OpenSSH_5.2p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to heroku.com [50.19.85.154] port 22.
debug1: Connection established.
debug1: identity file /Users/ohho/.ssh/identity type -1
debug1: identity file /Users/ohho/.ssh/id_rsa type 1
debug1: identity file /Users/ohho/.ssh/id_dsa type 2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-5pgsql1
debug1: match: OpenSSH_5.1p1 Debian-5pgsql1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'heroku.com' is known and matches the RSA host key.
debug1: Found key in /Users/ohho/.ssh/known_hosts:5
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/ohho/.ssh/identity
debug1: Offering public key: /Users/ohho/.ssh/id_rsa
debug1: Remote: Forced command: /home/git/bin/git_proxy [email protected]
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
debug1: Offering public key: /Users/ohho/.ssh/id_dsa
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
How to fix the Permission denied (publickey)
error?
UPDATE (file permission info):
drwxr-xr-x 11 ohho staff 374 Sep 16 09:37 .
drwxr-xr-x+ 50 ohho staff 1700 Sep 15 10:34 ..
-rw------- 1 ohho staff 1743 Sep 16 09:37 github_rsa
-rw-r--r-- 1 ohho staff 390 Sep 16 09:37 github_rsa.pub
-rw-r--r-- 1 ohho staff 390 Sep 9 09:47 github_rsa.pub_bak-github
-rw------- 1 ohho staff 1743 Sep 9 09:47 github_rsa_bak-github
-rw------- 1 ohho staff 736 Dec 2 2010 id_dsa
-rw-r--r-- 1 ohho staff 606 Dec 2 2010 id_dsa.pub
-rw------- 1 ohho staff 1743 Jan 28 2011 id_rsa
-rw-r--r-- 1 ohho staff 399 Jan 28 2011 id_rsa.pub
-rw-r--r--@ 1 ohho staff 10752 Sep 16 11:47 known_hosts
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我有同样的问题,可以解决:(
添加到heroku的公钥的私钥)
I had the same issue and could solve doing:
(private key for the public key added to heroku)
使用 msysgit,从 bash 会话检查
.ssh
目录的权限(它们应该是700
),以及其中的文件(600
) ).查看问题 261 并查看是否有解决方法之一有效,就像(如果其他一切都失败)将 ssh.exe 替换为 cygwin 中的 ssh.exe。
OP ohho 提到了SO问题“Heroku 项目的 git 克隆失败”,建议加载 Heroku 密钥(当它有与默认的 id_rsa 不同的名称):
这是一个解决方案,特别是如果您已经拥有 id_rsa 私钥(用于 Heroku 以外的其他目的)
With msysgit, check the permissions on your
.ssh
directory from a bash session (they should be700
), and the files in it (600
).Check out the issue 261 and see if one of the workaround works, like (if everything else fails) replacing the
ssh.exe
by one from cygwin.The OP ohho mentions the SO question "git clone fails for Heroku project", which recommends to load the heroku key (when it has a different name than the default
id_rsa
):That is a solution especially if you have already an
id_rsa
private key (for other purposes than heroku)我对此有同样的问题。
我有一个应用程序,然后创建另一个应用程序,同一帐户。第一个应用程序仍然可以使用 git,但无法在第二个应用程序中使用 git 执行任何操作,即使其他操作(例如日志...)仍然有效!
这对我有用:
- 清除heroku当前密钥:
删除您当前位于~/.ssh/或WindowsC:\Users\.ssh
的当前私钥
创建新密钥对:
ssh-keygen -t rsa -C "[电子邮件受保护] "
上传到赫罗库:
herokukeys:add
它将列出您当前拥有的密钥对,并询问您要上传的密钥对,输入数字
完成。
I have same issue on this.
I had an app, then create another app, same account. First app still works with git but can't do anything with git in second app even other actions (such as logs... ) still work!
This works for me:
- clear heroku current keys:
Delete your current private keys at ~/.ssh/ or windows C:\Users\.ssh
Create new key pair:
ssh-keygen -t rsa -C "[email protected]"
Upload to heroku:
heroku keys:add
It will list current key pairs you have and ask for the one you want to upload, enter number
Done.