拒绝许可(publickey)。致命错误:无法从远程仓库读取。

4

我已经阅读了大部分相关问题并尝试了大部分解决方案,但没有一个对我起作用。

我通过RailsInstaller安装了Rails和Git,并正在尝试从Windows 7将我的Rails应用程序上传到heroku,但是我无法上传,提示Permission denied (publickey),尽管我的密钥已经上传到heroku。

这是我最后一次尝试上传ssh密钥的日志:

firstname.lastname@LONMAX-LTETB9X /c/Users/firstname.lastname/mytinyurl
 (master)
$ heroku keys:clear
Removing all SSH keys... done

firstname.lastname@LONMAX-LTETB9X /c/Users/firstname.lastname/mytinyurl
 (master)
$ heroku login
Enter your Heroku credentials.
Email: email@yahoo.com
Password (typing will be hidden):
Could not find an existing public key.
Would you like to generate one? [Yn] Y
Generating new SSH public key.
Uploading SSH public key C:/Users/firstname.lastname/.ssh/id_rsa.pub... done
Authentication successful.

firstname.lastname@LONMAX-LTETB9X /c/Users/firstname.lastname/mytinyurl
 (master)
$ git init
Reinitialized existing Git repository in c:/Users/firstname.lastname/myti
nyurl/.git/

firstname.lastname@LONMAX-LTETB9X /c/Users/firstname.lastname/mytinyurl
 (master)
$ git add .

firstname.lastname@LONMAX-LTETB9X /c/Users/firstname.lastname/mytinyurl
 (master)
$ git commit -m "first"
On branch master
nothing to commit, working directory clean

firstname.lastname@LONMAX-LTETB9X /c/Users/firstname.lastname/mytinyurl
 (master)
$ 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.

firstname.lastname@LONMAX-LTETB9X /c/Users/firstname.lastname/mytinyurl
 (master)
$ heroku keys
=== email@yahoo.com Keys
ssh-rsa AAAAB3NzaC...rJqQanPQ== firstname.lastname@LONMAX-LTETB9X

有人能看出我做错了什么或者有什么建议吗?

更新

以下是我在运行verbose时获得的一些日志细节

 $ ssh -vvv git@heroku.com

OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug2: ssh_connect: needpriv 0
debug1: Connecting to heroku.com [50.19.85.132] port 22.
debug1: Connection established.
debug1: identity file /h/.ssh/identity type -1
debug3: Not a RSA1 key file /h/.ssh/id_rsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /h/.ssh/id_rsa type 1
debug1: identity file /h/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version Twisted
debug1: no match: Twisted
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-g
roup-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour1
28,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-c
tr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour1
28,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-c
tr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@open
ssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@open
ssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit: diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa
debug2: kex_parse_kexinit: aes256-ctr,aes256-cbc,aes192-ctr,aes192-cbc,aes128-ct
r,aes128-cbc,cast128-ctr,cast128-cbc,blowfish-ctr,blowfish-cbc,3des-ctr,3des-cbc

debug2: kex_parse_kexinit: aes256-ctr,aes256-cbc,aes192-ctr,aes192-cbc,aes128-ct
r,aes128-cbc,cast128-ctr,cast128-cbc,blowfish-ctr,blowfish-cbc,3des-ctr,3des-cbc

debug2: kex_parse_kexinit: hmac-sha1,hmac-md5
debug2: kex_parse_kexinit: hmac-sha1,hmac-md5
debug2: kex_parse_kexinit: none,zlib
debug2: kex_parse_kexinit: none,zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_init: found hmac-md5
debug1: kex: server->client aes128-cbc hmac-md5 none
debug2: mac_init: found hmac-md5
debug1: kex: client->server aes128-cbc hmac-md5 none
debug2: dh_gen_key: priv key bits set: 133/256
debug2: bits set: 529/1024
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug3: check_host_in_hostfile: filename /h/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 1
debug3: check_host_in_hostfile: filename /h/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 3
debug1: Host 'heroku.com' is known and matches the RSA host key.
debug1: Found key in /h/.ssh/known_hosts:1
debug2: bits set: 499/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /h/.ssh/identity (0x0)
debug2: key: /h/.ssh/id_rsa (0xa01a528)
debug2: key: /h/.ssh/id_dsa (0x0)
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /h/.ssh/identity
debug3: no such identity: /h/.ssh/identity
debug1: Offering public key: /h/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug2: input_userauth_pk_ok: fp ac:2f:88:b3:69:96:c5:f4:ba:f6:f6:9d:e6:ea:8f:cf

debug3: sign_and_send_pubkey
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: Trying private key: /h/.ssh/id_dsa
debug3: no such identity: /h/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).

提前感谢您


你是否添加了正确的代码库?你可以检查一下 git remote -v。 - Icicle
我认为是这样的,git remote -v 返回如下内容: heroku git@heroku.com:random-names-3207.git (fetch) heroku git@heroku.com:random-names-3207.git (push) - Sharethefun
请提供 gitssh 的位置(通常使用 which 命令)。 - Малъ Скрылевъ
2个回答

3
请确保您的公钥和私钥只有 /c/Users/firstname.lastname/.ssh 中的 id_rsaid_rsa.pub(没有 id_dsa 文件)。
即使您的密钥已上传到 Heroku,请再次确认 Heroku 的 keys:add 是否查看到您的公钥(Heroku 密钥管理),并且已经在 Heroku 端发布过了。 (还要确认它是正确的)。
请确保 git-bash 会话中始终将环境变量 HOME 设置为 /c/Users/firstname.lastname
请确保您的 ssh 密钥没有密码保护(首先,用于测试),并且您没有使用可能会混淆所使用的 ssh 密钥的 ssh 代理程序:请参见 "无法将 git 存储库推送到 Heroku,尽管 SSH 密钥有效"。
您也可以尝试重置密钥

-4

Git 不知道你的 SSH 密钥在哪里。你需要把它们放进去。

C:/Program Files/Git/.ssh/
C:/Program Files/Git/.ssh/

或者

C:/Program Files (x86)/Git/.ssh/
C:/Program Files (x86)/Git/.ssh/

只有这样,Git Bash 才能识别这些密钥。


2
用户的SSH密钥应该放在该用户的主文件夹中,而不是系统范围的文件夹中。正如VonC在他的回答中指出的那样,Git Bash将在用户的主文件夹中查找SSH密钥。 - user456814

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接