Git clone fails when cloning via SSH

Platform Notice: Cloud and Data Center - This article applies equally to both cloud and data center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

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.

1 2 3 4 5 6 7 8 $ 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.

Environment

Bitbucket Data Center

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

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

    1 2 # 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

If it has been confirmed that the correct key is being used, the problem may stem from an unidentified issue with the existing keys.

Solution

Updated on March 10, 2025

Still need help?

The Atlassian Community is here for you.