Permission denied (publickey). fatal: Could not read from remote repository.

I have an individual bitbucket account and am a member of a team on bitbucket.

Recently I created a new bitbucket repository on my individual account and pushed code from a local repository into it. I then transfered that repository from my individual account to my team account, and I accepted the transfer on behalf of my team.

After making some changes on my local code base i tried to push those changes to origin with a git push and received the following error message:

nw-client (master)]$ git push
fatal: https://[myname]@bitbucket.org/[myname]/nw-html-client.git/info/refs?service=git-receive-pack not found: did you run git update-server-info on the server?

I realized at that point that I needed to update my origin's URL, so I typed the following git command into the terminal:

git remote set-url origin git@bitbucket.org:[myteamname]/nw-html-client.git

But,

git ls-remote

returns

[nw-client (master)]$ git ls-remote
Permission denied (publickey).
fatal: Could not read from remote repository.

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

My git.config file looks like this:

[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
	ignorecase = true
	precomposeunicode = false
[remote "origin"]
	url = git@bitbucket.[myteamname]/nw-html-client.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master

What am I doing wrong? Any help would be greatly appreciated!

3 answers

1 accepted

4 votes

Hi Chuck,

Thank you for your question.

It seems you had your repository under the HTTPS protocol and once you set the URL origin your repository became to connect under the SSH protocol. Would be possible to generate a key-pair, add the public key to your Bitbucket repository and the private key to your ssh and give it a try, please.

Kind regards,
Rafael

That was it. Thanks!

I encountered the same problem but it my public ssh key was registered.  It turned out to be simply a DNS issue.  Once the hostname resolved everything was happy.

Could you provide more detail to this?

I'm sorry I don't recall much more than that.  I may have changed which network interface I was using to connect to the network or perhaps the IT department moved the repo to a new machine / IP address (thought that's unlikely).

I also encountered a similar problem recently, I could load my remote repositories but not clone/pull/push etc. As has happened before this had to do with locally adding the ssh key to my ssh-agent. This is a problem I've run into more often on mac. I found this article very useful:

https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#adding-your-ssh-key-to-the-ssh-agent

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

28,439 views 26 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you