Git: Permission denied (publickey) fatal - Could not read from remote repository. while cloning Git repository

后端 未结 30 1821
青春惊慌失措
青春惊慌失措 2020-12-12 10:10

I am unable to clone a Git repository, and getting this error:

krishna.soni@KRISHNACHANDRAS /c/Projects $ git clone http://stage.abc.com:10088/pqr
http://<         


        
相关标签:
30条回答
  • 2020-12-12 10:44

    I've had this issue on a Mac - while I setup SSH correctly to access my Git repository, after restart (and some time the Mac was on a standoff), all my credentials were removed. Apparently, for some reason the pub key was set to 644 which caused it to be removed from the keychain. To readd:

    • chmod 600 the public key
    • ssh-add ~/.ssh/[your private key] - this should display that identity has been added. The key file you want is the one without the .pub extension.
    • ssh-add -l should show you newly added identity

    edit: apparently MacOS has tendency of removing keys - after downloading the High Sierra update (but I've not installed it yet) my key has been removed and I've had to add it again via ssh-add

    0 讨论(0)
  • 2020-12-12 10:45

    For me, when i wanted to clone from my repository, i had the same message noticed before "Permission denied (publickey) fatal: Could not read from remote repository". The solution for my case is to not use sudo before clone That's it.

    0 讨论(0)
  • 2020-12-12 10:45

    I had a similar problem on linux. I solved the problem by logging into the github server and creating a deploy key. That's under settings for the repository. Then, I copied and pasted my public key (which is usually in ~/.ssh/id_rsa.pub, but your configuration might be different). There is a check box to give this key write access. Click on it (unless you are using git to deploy only, in which case, don't click on it).

    0 讨论(0)
  • 2020-12-12 10:46

    Remove remote origin

    git remote remove origin

    Add HTTP remote origin

    0 讨论(0)
  • 2020-12-12 10:48

    You need to create a new ssh key by running ssh-keygen -t rsa.

    0 讨论(0)
  • 2020-12-12 10:49

    You can try adding your ssh key to your private keychain. It worked for me

    ssh-add -K ~/.ssh/[your-private-key]
    
    0 讨论(0)
提交回复
热议问题