BitBucket - Git - 权限被拒绝(publickey)

时间:2015-03-28 11:46:07

标签: git ssh bitbucket

首先,我希望您知道我已经阅读了20多篇有关该主题的帖子。但是,它在2天后仍无法正常工作,所以...我终于放弃并承认我无法设置此ssh连接......

好的,痛苦的。现在这就是我所做的(至少3次):

  1. 我使用以下命令生成一组ssh密钥:

    ssh-keygen -t rsa
    
  2. 以下是.ssh文件夹和rsa keys的权限:

    $ ls -al | grep .ssh
    drwx------  2 local local     4096 mars  28 11:17 .ssh
    
    $ ls -al .ssh/
    -rw-r--r--  1 local local  802 mars  11 17:11 authorized_keys
    -rw-r--r--  1 local local   61 mars  28 11:17 config
    -rw-------  1 local local 1675 mars  28 11:14 id_rsa
    -rw-------  1 local local  396 mars  28 11:14 id_rsa.pub
    -rw-------  1 local local 1326 mars  25 17:38 known_hosts
    
  3. 我将id_rsa_.pub的内容复制到我的BitBucket帐户。我确信这是完美无瑕的,我三重检查。

  4. 我编辑了.ssh/config所以看起来像这样:

    $ cat .ssh/config 
    Host bitbucket.org
    IdentityFile /home/local/.ssh/id_rsa.pub
    
  5. 这是ssh -v git@bitbucket.org的输出:

    $ ssh -v git@bitbucket.org                                                                                                                                                                         
    OpenSSH_6.0p1 Debian-4+deb7u2, OpenSSL 1.0.1e 11 Feb 2013
    debug1: Reading configuration data /home/local/.ssh/config
    debug1: /home/local/.ssh/config line 1: Applying options for bitbucket.org
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 19: Applying options for *
    debug1: Connecting to bitbucket.org [131.103.20.168] port 22.
    debug1: Connection established.
    debug1: identity file /home/local/.ssh/id_rsa.pub type 1
    debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
    debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
    debug1: identity file /home/local/.ssh/id_rsa.pub-cert type -1
    debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
    debug1: match: OpenSSH_5.3 pat OpenSSH_5*
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u2
    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: Server host key: RSA 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40
    debug1: Host 'bitbucket.org' is known and matches the RSA host key.
    debug1: Found key in /home/local/.ssh/known_hosts:3
    debug1: ssh_rsa_verify: signature correct
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug1: SSH2_MSG_NEWKEYS received
    debug1: Roaming not allowed by server
    debug1: SSH2_MSG_SERVICE_REQUEST sent
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug1: Authentications that can continue: publickey
    debug1: Next authentication method: publickey
    debug1: Offering RSA public key: /home/local/.ssh/id_rsa.pub
    debug1: Remote: Forced command: conq username:happy-dev
    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 279
    debug1: key_parse_private_pem: PEM_read_PrivateKey failed
    debug1: read PEM private key done: type <unknown>
    Enter passphrase for key '/home/local/.ssh/id_rsa.pub': 
    debug1: No more authentication methods to try.
    Permission denied (publickey).
    
  6. 如果您知道我仍然收到Permission denied (publickey)消息,请与我分享。我非常绝望:D

1 个答案:

答案 0 :(得分:3)

IdentityFile /home/local/.ssh/id_rsa.pub

您在此处使用公钥文件。您应该使用私钥文件。它可能被称为id_rsa

IdentityFile /home/local/.ssh/id_rsa