1

I am trying to access my repositories on my bitbucket account via ssh, but no matter what I try, I can't seem to get access. I own all the repositories on my account as well, so it's not a matter of not having read/write privileges.

I created a new public/private key combo and added the public key to my account (I have done this with other computers as well). And I did the following commands in my command line:

eval 'ssh-agent' //I've also tried eval 'ssh-agent -s'
ssh-add /path/to/private/key

Still denied access. I have setup SSH access before on Bitbucket without any issues using this same process, but for some reason, I can't get this to work.

Update:

I ran ssh -v bitbucket.org and here was the output:

OpenSSH_7.2p2 Ubuntu-4ubuntu2.7, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /home/eric/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to bitbucket.org [18.205.93.0] port 22.
debug1: Connection established.
debug1: identity file /home/eric/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/eric/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/eric/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/eric/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/eric/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/eric/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/eric/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/eric/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.7
debug1: Remote protocol version 2.0, remote software version conker_1.1.53-1da6f80 app-155
debug1: no match: conker_1.1.53-1da6f80 app-155
debug1: Authenticating to bitbucket.org:22 as 'eric'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A
debug1: Host 'bitbucket.org' is known and matches the RSA host key.
debug1: Found key in /home/eric/.ssh/known_hosts:1
Warning: Permanently added the RSA host key for IP address '18.205.93.0' to the list of known hosts.
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/eric/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: eric@thanos
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: eric@thanos
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/eric/.ssh/id_dsa
debug1: Trying private key: /home/eric/.ssh/id_ecdsa
debug1: Trying private key: /home/eric/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).

It looks like it's trying to find a private key named id_rsa, which, for the computer I am working on now, is already in use on another bitbucket account, so it can't be used for this account. Is there some way to override that naming convention so that I can add a custom key not named id_rsa?

Eric Brown
  • 1,312
  • 3
  • 15
  • 30
  • could you provide more info? you can execute something like ssh -v bitbucket.org I think it should be something simple like your private key access mode is not 600, or it cannot find the private key – Alex Nikiforov Mar 30 '19 at 01:51
  • @AlexNikiforov I updated my question by adding the result of ssh -v bitbucket.org. – Eric Brown Apr 01 '19 at 19:03
  • Given that you have added you new private key to bitbucket, I suggest you to check ~/.ssh/config it should have something like `Host github.com User git IdentityFile ~/.ssh/github_rsa` Look it iterates over the keys, means it cannot find matching key in the ~/.ssh/ – Alex Nikiforov Apr 01 '19 at 21:04
  • I tried setting the config file, but it still didn't work for me. – Eric Brown Apr 01 '19 at 22:31

2 Answers2

0

First, try that with a private key without passphrase: you will avoid having to deal with the ssh-agent, which, for testing, is easier.

Second, make sure to generate a private key to the old PEM format, not the new OpenSSH one:

ssh-keygen -m PEM -t rsa -P "" -f afile

And see if the issue persists.

Your stack trace also includes:

Authenticating to bitbucket.org:22 as 'eric'

Make sure your SSH URL is git@bitbucket.org, not eric@bitbucket.org: the key is there to authenticate you within the session, but the session is always opened with the git account.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

I figured out what was causing the issue. By default, bitbucket looks for a private key named "id_rsa" when using the default git url (git@bitbucket.org:<username>/<repository>.git). Since mine was already tied to another account, it kept throwing up errors. It is, however, possible to add additional keys to the account using the information here:

https://confluence.atlassian.com/bitbucket/set-up-additional-ssh-keys-271943168.html.

Worked for me and now I have SSH access to my account.

Eric Brown
  • 1,312
  • 3
  • 15
  • 30