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

fatal: Could not read from remote repository.

Francesco Savino
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!
February 13, 2023

I have followed all steps to create remote repo ,Created SSH keys pair, and also been succed to clone repo locally .To day after , now , created some folders and done staging +commit .

Now I cant be able to push :

$ git push origin master
Enter passphrase for key '/home/devuser/.ssh/bitbucket':
Unauthorized
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

 

I inserted also in .ssh/config file  :

Host bitbucket.org

AddKeysToAgent yes

IdentityFile ~/.ssh/{ssh-key-name}

 

It's is strange because all git read operations works and test work fine

$ ssh -T git@bitbucket.org
Enter passphrase for key '/home/devuser/.ssh/bitbucket':
authenticated via ssh key.

You can use git to connect to Bitbucket. Shell access is disabled

 

Then where is the problem ?  please , help :)

1 answer

1 accepted

5 votes
Answer accepted
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 14, 2023

Hello @Francesco Savino ,

Welcome to Atlassian Community! 

As you mentioned that read operations (clone, pull) work and the issue happens only with write operations (push), I suspect you might have added the SSH key as an Access key.

SSH keys added as Repository or project access keys provide just read access to repositories. So you will be able to only clone and pull using a repo/project access key. The only access key that provides read and write access are Workspace Access keys (see Difference between repository, project and Workspace access keys ).

If you want the key to have the same access to repositories as your user account does, then you need to add the key to your user profile by going to Your avatar in the top right > Personal Settings > SSH keys

It's important to note that you cannot use the same key both as access keys and personal keys.

With that in mind, could you please confirm if the key you are using was added as an access key at the repo or project level? If yes, you can then try either adding it as a personal key or as a workspace access key.

Thank you, @Francesco Savino !

Patrik S

gh_inet
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!
August 7, 2023

Hi @Patrik S ,

It seems that I have a similar problem. I changed the computer and added a second SSH key, which I created new on my second laptop.

 ssh-keygen -t rsa -b 2048 "gerXX.XXX@gmail.com" -f id_bitbucket


Then I added the SSH key to my account (Personal Settings > SSH keys).

The test is working:

$ ssh -T git@bitbucket.org
authenticated via ssh key.

You can use git to connect to Bitbucket. Shell access is disabled

I still get 

> git pull --tags origin master
Unauthorized
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Thank you for your help!


Kind regards,


Gernot

Like Chris Frewin likes this
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 15, 2023

Hello @gh_inet ,

I suspect the new key you created is not being used by SSH. To confirm if that is the case, could you please create a file named config inside the folder ~/.ssh/ and add the following content to it : 

Host bitbucket.org
AddKeysToAgent yes
IdentityFile ~/.ssh/{name of your SSH key}

The IdentityFile section should contain the full path to the new key you created. This will force SSH to use the provided key when authenticating requests to bitbucket.org.

You can also try using the verbose flags in the git command so it will output logs containing more details about the ssh keys that were found in your local machine and the order they are being used : 

GIT_TRACE_PACKET=1 GIT_TRACE=1 GIT_SSH_COMMAND="ssh -vvv" git pull --tags origin master

Thank you, @gh_inet !

Patrik S

Like MattSerra likes this
kuno vaik November 8, 2023

I have same error.

 

i added config file, but this is not resolved the problem.

Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 8, 2023

Hello @kuno vaik ,

I would like to ask if you could please create a new question for your issue, providing details on the errors you see and also the output of the git command with the verbose log flags as mentioned above. 

We generally encourage users to create a new question for their issue instead of posting on someone else’s question, because

1) the root cause and resolution may be different for each case

2) a question can become cluttered and difficult to follow if we try to troubleshoot multiple users’ issues in it.

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

Thank you, @kuno vaik  !
Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events