Am I trying to perform the impossible with a free account?
Asked by kiusau:

This is where I have finished:

% git remote add origin git@bitbucket.org:kiusau/deflation-made-simple.git  
% git push -u origin master:master  
Unauthorized  
fatal: Could not read from remote repository.

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

This is where I started:

% cat \~/.ssh/id_rsa.pub \| pbcopy  
% ssh -T git@bitbucket.org  
authenticated via ssh key.

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

Is there something more that I must do, or must I do things in a different way?

Roddy

ps: Debugging Output  

% ssh -v git@bitbucket.org  
OpenSSH_8.8p1, OpenSSL 1.1.1m 14 Dec 2021  
.  
.  
.  
Authenticated to bitbucket.org (\[104.192.141.1\]:22) using "publickey".  
debug1: channel 0: new \[client-session\]  
debug1: Entering interactive session.  
debug1: pledge: filesystem full  
PTY allocation request failed on channel 0  
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0  
authenticated via ssh key.

You can use git to connect to Bitbucket. Shell access is disabled  
debug1: channel 0: free: client-session, nchannels 1  
Connection to bitbucket.org closed.  
Transferred: sent 3420, received 2296 bytes, in 0.2 seconds  
Bytes per second: sent 19820.9, received 13306.7  
debug1: Exit status 0


Answers:
author: Jack Nolddor [Sweet Bananas]
body: Hi and welcome,

Have you added the generate SSH key pair to your bitbucket account on the website?  

Check this page

<https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/>

specially the 'Step 3. Add the public key to your Account settings' part.

Best Regards

comments: author: kiusau
body: Hello, Jack!

Initially, I added my public key to my Personal Account Settings, and it did not work. This was likely due to bad mapping on my local machine. Thinking that I had added it in the wrong place, I did two things:

1) I selected a different public key that I knew worked in other environments, and

2) Added my public key to Repository Settings.

At your suggestion, I tried to add the same public key to my personal account settings and was told the following:

"Someone has already added that key as an access key to a repository."

Are you suggesting that, if I remove the public key from my Repository Settings to my Personal Account Settings that the problem will go away?

Roddy


author: Jack Nolddor [Sweet Bananas]
body: Yes, you must setup your public key at your user settigs, this way that keypair will have access to any repository related bitbucket user has.

**Did my initial answer solved your problem?** *Don't hesitate to mark the reply as Answer Accepted*

Regards


author: kiusau
body: Hi, again Jack!

So, I removed my functioning public key from my repository settings to my personal account settings and tried again. The following is what occurred:

% git push -u origin master:master  
To bitbucket.org:kiusau/deflation-made-simple.git  
! \[rejected\] master -\> master (non-fast-forward)  
error: failed to push some refs to 'bitbucket.org:kiusau/deflation-made-simple.git'  
hint: Updates were rejected because the tip of your current branch is behind  
hint: its remote counterpart. Integrate the remote changes (e.g.  
hint: 'git pull ...') before pushing again.  
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

% git branch --set-upstream-to=origin/master master  
branch 'master' set up to track 'origin/master'.  
git pull --all  
Fetching origin  
fatal: refusing to merge unrelated histories  
%

Please advise further. You appear to be knowledgeable.

Roddy


author: kiusau
body: I resolved the problem by first pulling from my Bitbucket repository with

git pull origin master --allow-unrelated-histories

And, then pushing with

git push -u origin master:master

And, yes there was a lot of fumbling inbetween as I sought to sort out the various GIT-provided error messages, but in the end success was achieved:

% git push -u origin master:master  
Enumerating objects: 74, done.  
Counting objects: 100% (74/74), done.  
Delta compression using up to 6 threads  
Compressing objects: 100% (71/71), done.  
Writing objects: 100% (73/73), 1.22 MiB \| 15.25 MiB/s, done.  
Total 73 (delta 26), reused 0 (delta 0), pack-reused 0  
To bitbucket.org:kiusau/deflation-made-simple.git  
7a614f3..ef23a06 master -\> master  
branch 'master' set up to track 'origin/master'.  
%

Hooray! Hooray! Hooray!

I believe that I have even figured out the meaning of the originally confusing message:

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

My repository is on the Cloud. I do not have a server account. Is this correct?

Thank you, and have a great day!

Roddy