I am logged in but bitbucket throws an error when I try to push

dfiler:~/workspace/sample_app (master) $ git push -u origin --all
ssh: Could not resolve hostname gitbitbucket.org: Name or service not known
fatal: Could not read from remote repository.

I get the above error message. What am I doing wrong?

 

Don filer

2 answers

1 accepted

0 votes
Accepted answer

Thanks, Brian,

     I deleted the repository that was not taking my changes. I resubmitted my SSH Key and I initialized the repository again. When I pushed the project up it  indeed was missing the @ sign in the address but I included it in the git remote add origin command and it responded that it was there. I might be doing something wrong, but I can't determine what it is from my end.
Bryan Turner Atlassian Team Jun 16, 2016

When you say "it responded that it was there", I think that's an error saying there's already an "origin" remote, not that the @ sign was already present. If the remote exists, you either need to git remote rm origin to remove it, or you need to use git remote set-url origin ... to change it.

I tried changing the remote address, adding the @ sign but when I tried to push this is what I got.

dfiler:~/workspace/sample_app (master) $ git remote set-url origin git@bitbucket.org:donfiler/sample_app.git
dfiler:~/workspace/sample_app (master) $ git push -u origin --all
Warning: Permanently added 'bitbucket.org,104.192.143.1' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Bryan Turner Atlassian Team Jun 16, 2016

"Permission denied (publickey)" indicates you have not setup your SSH key correctly at bitbucket.org. Since your public key isn't setup, Bitbucket rejects your SSH request.

3 votes
Bryan Turner Atlassian Team Jun 16, 2016

Don,

I think you've got a bad remote URL in your repository. It looks like you've got "gitbitbucket.org", but what it should be is "git@bitbucket.org", where "git" is the username and the host address is "bitbucket.org". Note that "git" will always be the username, not your username. Even though you push with the "git" username, your username will be associated with the push because the SSH key used to authenticate with the server is associated with your account.

You can confirm your URL by running git remote -v to see what it is. If it's not correct, you can use something like git remote set-url origin git@bitbucket.org:<user>/<repo>.git, where you'll need to substitute in the <user> and <repo> you're trying to push to. Unfortunately I can't glean that from the error snippet posted. You can get the exact URL you should use from the Bitbucket UI; it will be called the "Clone URL". It's shown in the upper-right corner on the overview, or by clicking the "Clone" action in the sidebar.

If you haven't associated an SSH public key with your Bitbucket account, you'll be unable to push over SSH even using the correct URL. This tutorial can help you set up your SSH key if you haven't already.

Best regards,
Bryan Turner
Atlassian Bitbucket 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

197 views 3 6
Read article

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