Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to clone git repo on remote server

Bryan Cruz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 13, 2024

Coming back to bitbucket after a while.

I setup a new repo, got a remote server and added an ssh key for the sudo user (not root), then added the access key in Repository Settings -> Security -> Access keys.

I go to remote server, `eval (ssh-agent -s)`, then add the only key I have to the `ssh-add`, make sure it's there by `ssh-add -l` and lastly try to clone with `sudo git clone git@bitbucket.org:namespace/repo.git`, but I always get the "Permission denied (public key)" error. Am I missing something?

 Any help is appreciated, thanks!

2 answers

3 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 16, 2024

Hi Bryan and welcome to the community!

You can use a config file to specify that this key should always be used for SSH operations to Bitbucket Cloud.

The content of that file could look as follows:

Host bitbucket.org
AddKeysToAgent yes
IdentityFile ~/.ssh/id_ed25519

where ~/.ssh/id_ed25519 should be the path to the private key file and the private key's name.

The location of this file is ~/.ssh/config and you can create the config file if it doesn't exist already in ~/.ssh.

However, you are executing the clone command with sudo and you also mention the sudo user (not root). Sudo is not a user, it just executes commands as root, so I'm not sure what you mean by that last part.

The path of IdentityFile in the config and also the location of the config file should be the ones of the user you are executing the clone command with.

If you're still experiencing issues, you can run the clone command as follows to get more verbose output:

sudo GIT_SSH_COMMAND="ssh -vvv" git clone git@bitbucket.org:workspace-id/repo.git

The output will show which files are being offered and which config is applied. You could also post the output here (after sanitizing the repo URL) so I can take a look.

Kind regards,
Theodora

1 vote
Nicolas Grossi
Banned
July 13, 2024

@Bryan Cruz Welcome you might misconfigured the ssh key on your related environments, please review that properly.

 

Nicolas 

Bryan Cruz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 13, 2024

@nico thank you so much for the reply!. Just to make sure there are not weird env situations, I tried recreating the key with:

ssh-keygen -t ed25519 -b 256 -C "sameemailforbitbucketaccount@gmail.com"


then adding it to the ssh agent with ssh-add

ssh-add ~/.ssh/id_ed25519

went to Access keys again, deleted the old key and added the new one from:

cat ~/.ssh/id_ed25519.pub


then trying the clone again:

sudo git clone git@bitbucket.org:namespace/repo.git

Is there something that seems out of place here?

There definitely something I'm missing, I just can't seem to figure It out.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events