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

SSH Access - Permission denied (publickey).

ron w May 25, 2021

Using VSCode (running in a linux container), I am able to push changes to my bitbucket account using HTTPS, but not SSH, as I get the following...

git@bitbucket.org: Permission denied (publickey).

fatal: Could not read from remote repository.

AFAICT I have configured it correctly, but looking on-line, the documentation states that the format of the clone URL's should be...

HTTPS: https://<repo_owner>@bitbucket.org/<accountname>/<reponame>.git

SSH: git@bitbucket.org:<repo_owner>/<reponame>.git

However, when I login in to my bitbucket account and go to my project, the clone address for SSH is in the format git@bitbucket.org:<accountname>/<reponame>.git, which is not correct.

I have tried using git remote set-url origin to set the URL, and running, git remote -v does show the correct details, but the details in my project on my bitbucket account still shows the wrong address.

I think? this is the cause of my problem, but unless I can change it, I won't know for sure.

How do I change this URL?

2 answers

1 accepted

0 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 26, 2021

Hi @ron w and welcome to the community.

Regarding the clone URLs, these should be:

HTTPS: https://<username>@bitbucket.org/<workspace-id>/<repo-slug>.git

SSH: git@bitbucket.org:<workspace-id>/<repo-slug>.git

where <username> is the username of your Bitbucket account that you are authenticating with
and <workspace-id> is the Id of the workspace that owns the repo

I'm not sure what documentation you were checking, would you mind posting the link here so I can take a look, in case something is wrong in the doc?

You mentioned:

However, when I login in to my bitbucket account and go to my project, the clone address for SSH is in the format git@bitbucket.org:<accountname>/<reponame>.git, which is not correct.

Do you get this clone address from Bitbucket website, if you log in, open the repo, and from it Source page select the link Clone?

If so, the URL listed there should be the correct one and should use the workspace-id.
The workspace-id should also be visible in the address bar of your browser, while you are viewing this repo, e.g.

https://bitbucket.org/<workspace-id>/<repo-slug>/src/master/

 

1. My first suggestion here would be to change the URL of the repo to git@bitbucket.org:<workspace-id>/<repo-slug>.git as I explained above, in case it is not already like that.

 

2. Afterwards, attempt to push from VSCode.

 

3. If you still get the same error, I would suggest navigating to the repo directory from a command line tool, and try to push from command line. This is to understand whether the issue may be specific to VSCode or not.

 

4. If this fails as well, I would like to ask if you could try the push, again from command line, with the following flags:

GIT_SSH_COMMAND="ssh -vvv" <git push command>

and copy-paste the output here so we can take a look.

(Please make sure to sanitise any sensitive info from the output, e.g. usernames, workspace-ids or repo names, prior to posting it here).

The command above will give verbose output and quite possibly an indication of what may be going wrong.

Please feel free to let me know if you have any questions.

Kind regards,
Theodora

ron w May 26, 2021

Hi Theodora,

Thank you very much for your answer :-) It turns out that both you and the bitbucket site both had the correct information, and not the other various sources that I found on-line.

I didn't get the information from the bitbucket site, but from another site. I would post the URL, but I deleted all the pages about 20 minutes ago (just before I read your reply!) in jubilation of finally fixing the issue, after 12 hours!!!

The solution to the problem was two-fold...

1) When using the bitbucket/jira extension in VSCode, the SSH key MUST be called id_rsa.

2) The SSH key MUST NOT have a passshrase.

If the rules above are not adhered to, then push, pull, etc, will work from the VSCode terminal (as I just found out), but not from the menu items!

Regards

Ron

ron w May 26, 2021

Hi Theodora,

Actually, I just found that page with the mis-information that I mentioned, and it was actually a bitbucket site. The URL is here...

https://support.atlassian.com/bitbucket-cloud/docs/configure-ssh-and-two-step-verification/

Regards

Ron

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

Hi Ron,

I'm glad that you managed to resolve the issue, and thanks for sharing the solution!

Thank you so much also for providing the URL of the doc, I will bring this up with the team responsible for the documentation, as I believe the URLs listed there need to be fixed.

If you need anything further, please feel free to reach out!

Kind regards,
Theodora

0 votes
Nirmala.Manipandian March 16, 2022
SSH: git@bitbucket.org:<workspace-id>/<repo-slug>.git
worked in windows 10

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events