Search code examples
gitsshbitbucketgit-clone

Can pull into a newly cloned repo with SSH key but not existing one on same machine


I'm trying to do a git pull from my bitbucket repository on my remote machine via SSH

But whenever I try to pull it asks for a password but I have SSH keys setup already.

The command $ssh -T [email protected] works fine and returns authenticated via ssh key.

I can even clone to a different folder with git clone [email protected]:xxxx/xxxx.git and then do git pulls into that newly cloned repo successfully. It's just whenever I navigate into the original local repo and try and pull in there, it asks for a password.

Any idea what's going on?


Solution

  • . It's just whenever I navigate into the original local repo and try and pull in there, it asks for a password

    When you are in the root folder of that repository, double-check its remote URL:

    git remote -v
    

    If it starts with https://bitbucket.com/... instead of [email protected]:..., that would explain the prompt for password.

    If not, check also git config -l | grep -i insteadOf: you might have an url.<base>.insteadOf config rule which would change any SSH URL into an HTTPS one.