Bitbucket/Github: permission denied public key

when I am trying to clone a rails app repo I have got permission to, I am getting this issue.

Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Even after adding public key by generating one, I am unable to solve this.

  • How to add TAG to a already committed in Git and Bitbucket
  • Backup a local working directory on BitBucket - clone or push
  • Configuration of 2 Bitbucket accounts on one laptop: cannot clone code
  • Jenkins returned status code 128
  • How do I configure Git to pull from one repo and push to another?
  • Isolate specific folders from updating on git
  • Although I am able to clone using he https method but after making changes, the same error comes while I try to push the code.

    Please suggest an answer for this.

  • git not uploading all files
  • Updates were rejected because the tip of your current branch is behind
  • Enabling Shortcut Keys in Eclipse
  • Can I check the existence of a git repo using an SSH URL?
  • Install ZendFramwork 2 on XAMPP on Windows
  • How do OpenPGP-signed git commits affect commit size?
  • 3 Solutions collect form web for “Bitbucket/Github: permission denied public key”

    First, cd into your .ssh directory. Open up the terminal and run:

    cd ~/.ssh && ssh-keygen

    Second, you need to copy this to your clipboard:

     cat | pbcopy # On OSX
     cat | xclip # On Linux

    Third, add your newly generated ssh key to your account via the github/bitbucket website (just paste there).

    Next, setup your git config:

    git config --global 'your_user_name'
    git config --global 'your_email'

    Finally, restart your command line to make sure the config is reloaded.

    Now, you should be able to clone and push from/to your github repository.

    For more information on this, see this github page or this bitbucket page.

    Check few things.

    1. Is the generated new key is the one your ssh agent using when trying to ssh to server.
      (Your ssh agent might be using a different key than the one you generated)
      use this to list currently loaded keys by agent.

      ssh-add -L

    2. You properly added public key to your repository hosting location.

    The keys corresponding to above 1 and 2 should match.

    Please see this article: GitHub: Generating SSH Keys. What happens when you run:

    ssh -T


    You may have added the wrong key to authenticate with.

    Git Baby is a git and github fan, let's start git clone.