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!
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
@Bryan Cruz Welcome you might misconfigured the ssh key on your related environments, please review that properly.
Nicolas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.