SSH Key error while pushing info to BitBucket

When I used Ruby on Rails to create sample project on my virtual machine using Ubuntu, I created an SSH key and saved in the folder ~/.ssh/id_rsa.pub

I have also saved this SSH key on Bit Bucket.

But error of invalid key comes when try to push this.

When I use cloud environment for ROR projects, I could push the information of the project to Bit Bucket without any error.

Also in Ubuntu 2 separate SSH keys were created probably when I was in 2 different directories like ~/workspace or ~/workspace/hello_app

I however uploaded both the SSH keys on Bitbucket.

 

So how to resolve the error when trying to push the info to Bitbucket repository from my virtual machine using Ubuntu.

 

 

4 answers

0 vote
Boris Berenberg Community Champion Jun 10, 2015

What is the actual error you are getting?

I am getting the following error:

~/workspace/hello_app$ git push -u origin --all

Permission denied (publickey).

fatal: Could not read from remote repository.

 

Please make sure you have the correct access rights

and the repository exists.

I created the key as follows and copied the public key to the directory  ~/.ssh/ :

$ ssh-keygen -t rsa (this command was made while in home directory)

Generating public/private rsa key pair.

Enter file in which to save the key (/home/venkata/.ssh/id_rsa): id_rsa

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in id_rsa.

Your public key has been saved in id_rsa.pub.

and then using cat command, displayed and then copied to Bitbucket. The repository hello_app was created in BitBucket. Presently this repository is empty.

 

 

 

 

 

 

 

 

 

 

0 vote

Hi Venkata, 

Can you let us know what happens when you run the following command?

$ ssh -T git@bitbucket.org

This might not be your case, but as a quick test, what happens if you run the push command using sudo in front of?

 

Also, this can happen due to a variety of reasons such as 1) your public key not loaded in your Bitbucket account 2) your key not loaded onto your ssh-agent etc.

This document does a good job of walking you through the process of troubleshooting your problems. There is a specific section for the Permission denied (publickkey) error as well that you might find useful.

 

Regards, 

Renato Rudnicki

I found out the error. When I generated key while in ~/.ssh/ instead of generating it while in another directory,  the key started working and I could push the info to repository. Thank you.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,745 views 1 5
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