Alexandre Bourlier
Alexandre Bourlier

Reputation: 4118

BitBucket - Git - Permission denied (publickey)

First of all, I would like you to know that I have read thoroughly 20+ posts on the topic. However, it is still not working after 2 days, so... I finally give up and acknowledge that I CANNOT set up this ssh connection...

Ok, painful enough. Now here is what I did (at least 3 times) :

  1. I generate a set of ssh keys with the command :

    ssh-keygen -t rsa
    
  2. Here are the permissions for both the .ssh folder and the 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. I copied the content of id_rsa_.pub to my BitBucket account. I am sure this is done flawlessly, I triple checked.

  4. I edited .ssh/config so it looks like this :

    $ cat .ssh/config 
    Host bitbucket.org
    IdentityFile /home/local/.ssh/id_rsa.pub
    
  5. And here is the output of ssh -v [email protected] :

    $ ssh -v [email protected]                                                                                                                                                                         
    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).
    

If you have any idea why I still get the Permission denied (publickey) message, please do share it with me. I am in great despair :D

Upvotes: 0

Views: 1900

Answers (1)

Kenster
Kenster

Reputation: 25380

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

You're using the public key file here. You should use the private key file instead. It's probably called id_rsa:

IdentityFile /home/local/.ssh/id_rsa

Upvotes: 4

Related Questions