Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.9k views
in Technique[技术] by (71.8m points)

Can't git push to Bitbucket: Unauthorized - fatal: Could not read from remote repository

I can't push to Bitbucket and this is the error message:

> git push origin master:master
Unauthorized
fatal: Could not read from remote repository.

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

Debugging, I receive this message when I ssh to bitbucket:

> ssh -T bitbucket.org
authenticated via a deploy key.

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

This deploy key has read access to the following repositories:
my-username/my-repository

The read access part of this message is suspicious.

PS: I know there are dozens of similar questions, but I couldn't find the exact error message here and only got the solution outside. That's why I'm self answering this to help others.

question from:https://stackoverflow.com/questions/56828685/cant-git-push-to-bitbucket-unauthorized-fatal-could-not-read-from-remote-re

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I was able to solve this using this suggestion:

  1. Remove the SSH key from the repo. (Click on repo name > Settings > Access Keys)
  2. Add SSH key to Account settings SSH keys. (Click on your avatar > Bitbucket Settings > SSH Keys)

So, adding the keys under the repo only gives you a read-only access. For read and write access, you need to add your keys under your account.

To be fair, Bitbucket warns about the read-only access when adding the key to the repo: image showing the bitbucket message warning about the read-only access


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...