githubgitbucket

GitBucket SSH Based Authentication


I configured the SSH based authentication as below

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://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