Search code examples
gitsshkeybitbucketpublic

Bitbucket Permission denied (publickey). but works with ssh


Hello, if i try to connect with bitbucket.org using ssh

ssh -vT [email protected]

Everything works fine

debug1: Authentication succeeded (publickey).

But if i try to use the git clone command i recive this message:

Permission denied (publickey).
fatal: The remote end hung up unexpectedly

Some extra information:

  • I already included the public key in my Bitbucket account
  • I have the keys located in ~/.ssh/
  • I am not running with sudo
  • The command ssh-add -l returns the correct key. (RSA)

Solution

  • I was able to make this work, but there was multiple problems with my git implementation:

    • I was trying to access a organization repository but i added the public key to my main account.
    • I was trying to use git clone with the pattern [email protected], after trying with git@bitbucket.org everything worked.

    I hope this helps someone with the same problem i had.