After successfully cloning my repo from heroku and added another remote
1/ git clone git@heroku.com:[APP].git
2/ git remote add bitbucket ssh://git@bitbucket
I would like to re-emphasize the following:
Took me ages to realise, somehow even after reading the answers here it didn't click.
First confusion on my side was about where exactly to set SSH Keys in BitBucket.
I am new to BitBucket and I was setting a Deployment Key which gives read-access only.
So make sure you are setting your rsa pub key
in your BitBucket Account Settings.
Click your BitBucket avatar and select Bitbucket Settings(Manage account). There you'll be able to set SSH Keys.
I simply deleted the Deployment Key, I don't need any for now. And it worked
Deployment keys are read only. To enable write access you need to:
Remove this deployment key from your repository settings. You won't be able to write to this repo with this key anyway.
Go to "Avatar -> Settings -> SSH Keys" and add the same key
Now try to push to remove branch
You were able to write to repositories before but this is a change in BitBucket where you're no longer able to write with deploy key.
Steps:
Create ssh keys on source server
ssh-keygen
Cat and copy id_rsa.pub located under ~./ssh directory
Check if it works by running below command on the source server
git remote show origin
For fetch and push from the source server, if the protocol is 'https' then you have to change it to 'git+ssh' by running below command
git remote set-url origin git+ssh://<bitbucketaccount>@bitbucket.org/<accountname>/repo.git
Check if you can do push to the repo.
Done!
I had the same issue Kabir Sarin had. The solution was to clone the repo via SSH, instead of using the https URL. so this is what helped me, and hopefully others:
git clone git@bitbucket.org:{accountName}/{repoName}.git
Recently I faced the same issue. I got the following error:
repository access denied. access via a deployment key is read-only.
You can have two kinds of SSH keys:
I simply removed my repository SSH key and added a new SSH key to my account and it worked well.
I hope it helps someone. Cheers