Search code examples
githubgitbucket

GitBucket SSH Based Authentication


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?


Solution

  • 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://[email protected]/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