2

I configured the SSH based authentication as below

  • Created a public key on my UNIX server
  • Added the public key on my Bitbucket repository with reading and write privileges (also tried it at account level)
  • changed the URL from https to SSH at bitbucket and Unix server
  • verified the URL using and it is displaying SSH URL only

Then Tried to push, but I am getting the below error:

Permission denied (public key). fatal: Could not read from remote repository. 
Please make sure you have the correct access rights and the repository exists.

I have read and write access to the repository push command git push -u origin master

Any idea?

1 Answers1

0

You should try:

GIT_SSH_COMMAND="ssh -Tv" git push

You will see what Git is using as an SSH key, and if there are any error messages.

If the error persists, it is possible there is something preventing SSH to operate properly (as in here, when not connected to a VPN)

Using HTTPS, of course, is a workaround:

git remote set-url origin https://git@bitbucket.XXX.com/XXX.com/XXX.git

After discussion, the missing step was to add the private key to the ssh-agent

ssh-add OEDQ_BIT added the private key
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackoverflow.com/rooms/222548/discussion-on-answer-by-vonc-gitbucket-ssh-based-authentication). – Samuel Liew Oct 05 '20 at 15:42
  • Hi When I am using https it is working but I need to manually enter the password and username – Vishnu Sajeevan Oct 07 '20 at 05:05