权限被拒绝(publickey)。致命:无法从远程存储库读取

时间:2014-07-09 10:59:54

标签: ruby-on-rails windows git heroku railsinstaller-windows

我已经阅读了大部分相关问题并尝试了大部分解决方案,但没有任何方法对我有用。

我已经通过RailsInstaller安装了Rails和Git,我试图将我的rails应用程序从Windows 7上传到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

任何人都可以看到我做错了什么或有任何建议吗?

更新

以下是关于我在详细信息

上运行时获得的日志的更多详细信息
 $ 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).

提前致谢

2 个答案:

答案 0 :(得分:2)

确保您只有/c/Users/firstname.lastname/.ssh公钥和私钥id_rsaid_rsa.pub(没有id_dsa文件)

即使您的密钥已上传到heroku,double-check that heroku keys:add也会看到您的公钥(heroku key management),并且已确认它已在Heroku端发布。 (和that it is the right one

确保在git-bash会话中始终将HOME设置为/c/Users/firstname.lastname

确保您的ssh密钥不受密码保护(首先,用于测试),并且您没有可能与使用的ssh密钥混淆的ssh代理:请参阅“Unable to push git repo to Heroku, despite valid SSH keys”。< / p>

你也可以try and reset the keys

答案 1 :(得分:-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才能识别密钥。