Git clone fails due when cloning via SSH

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Server and Data Center Only - This article only applies to Atlassian products on the server and data center platforms.

Problem

Git clones fail when using ssh even if an Access key has been added to the repository or an SSH key has been added to the user's profile.

$ git clone ssh://git@<bitbucket URL>:<bitbucket port>/<project key>/<repository slug>.git
Cloning into '<repository slug>'...
Repository not found
The requested repository does not exist, or you do not have permission to access it.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Diagnosis

Diagnostic Steps

  • Ensure an SSH key has been added to the user or the repository
  • Check the existing keys on the client by running

    ssh-add -l
  • Attempt to clone a change to the repository with the Git client debug on:

    # Example on Linux
    GIT_SSH_COMMAND="ssh -vvv" git clone ssh://git@<bitbucket URL>:<bitbucket port>/<project key>/<repository slug>.git

    The log will show which key has been used for the authentication and which ones have been tried. The line to check will look like the following:

    debug1: Offering RSA public key: /Users/<username>/.ssh/id_rsa

Cause

Once excluded that the correct key is used, this may be caused by an unknown issue with the existing keys.

Resolution

  • Recreate the keys


Last modified on Sep 13, 2019

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.