Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Cannot clone repo, but SSH works and user has read rights.

Sinus Pi October 6, 2021

I'm setting access for another user on Bitbucket.

  • They added SSH public keys to their account,
  • they set up private keys on their machine,
  • `ssh -T git@bitbucket.org` gives a proper "logged in as username, you can use git" response,
  • I did set their account's permission to the repo as "read".

But still, `git clone git@bitbucket.org:workspacename/reponame.git` fails with "Connection closed by 104.192.141.1 port 22  fatal: Could not read from remote repository.".

What else can I do to diagnose this?

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 8, 2021

Hi @Sinus Pi,

I would suggest checking the following:

  •  If the user has access to a different network, ask them to try cloning your repo while connected to this other network (using the same machine). That would help narrow down whether the issue seems to be network-specific or not.
  • Is the user able to clone the following public repo via SSH? This is to understand if the issue seems to be specific to the repo or not.
  • You can ask the user to try cloning your repo using the following command. This will give more verbose output, and it may also give an indication of what may be going wrong.
    GIT_SSH_COMMAND="ssh -vvv" git clone git@bitbucket.org:workspacename/reponame.git

Kind regards,
Theodora

Sinus Pi October 8, 2021

I applaud your multi-faceted approach. :)

In the meantime I figured out something similar - ssh was using a private key from .ssh/id_rsa, but git was trying to rely on (possibly misconfigured) ssh-agent. I didn't get to investigate in more detail, because our spare repo worked for the user attempting this and there was no point to keep trying this one.

However, the takeaway would be that it could make sense to amend your documentation, to take into consideration that even while `ssh -T git@bitbucket.org` may be working, `git clone git@bitbucket.org/project/repo.git` may not.

Or that's how it looked, anyway.

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 12, 2021

Hi @Sinus Pi,

Thank you for your reply and feedback.

Is the user able to clone if they add the key ~/.ssh/id_rsa to the SSH agent, with the following command?

ssh-add ~/.ssh/id_rsa

They can also specify the private key to be used with Bitbucket in the ~/.ssh/config file, with an entry like the following:

Host bitbucket.org
HostName bitbucket.org
IdentityFile ~/.ssh/id_rsa

I have attempted to reproduce the behavior you reported, but I'm afraid I haven't been able to. I'm not sure if the issue is specific to the ssh client and/or agent used, or possibly also the ssh configuration on the user's machine.

If you wouldn't mind sharing some details, like
1) operating system and version of the user
2) what SSH client is used and what version
3) whether there is any config in the ~/.ssh directory of the user, either specific to bitbucket.org or for Host *
4) The version of Git used

I can attempt to reproduce, so we can see under what circumstances the issue occurs and amend the documentation.

Kind regards,
Theodora

Like David Searle likes this
David Searle June 8, 2022

I experienced the same symptoms as the original poster.

I was able to track it down to the fact that my private key was named bitbucket_rsa instead of id_rsa.

I was able to use the debugging steps and solution provided by @Theodora Boudale . The solution for me was creating the Host entry in the ~/.ssh/config file with the proper IdentityFile specified.

 

Thanks,

Dave

Like Theodora Boudale likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events