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

后端 未结 30 1818
青春惊慌失措
青春惊慌失措 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:51

    After changing permissions of folder in which I was cloning, it worked:

    sudo chown -R ubuntu:ubuntu /var/projects

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

    I had the similar issue. I change the ssh keys and restarted and tried all other 'n' solutions. But the actual issue for me was our gitlab default protocol changed from ssh to https.

    check the remote url with

    git remote -v
    

    change the remote url

    git remote set-url origin https://URL
    
    0 讨论(0)
  • 2020-12-12 10:54

    In macOS / Linux (Ubuntu):

    1. To Authenticate you need to add your public part of your SSH key pair to bitbucket from within your user settings: User Settings --> SSH keys

    You will find the said public part in your ~/.ssh directory, usually id_rsa.pub . note the .pub part of the file name for Public. it will help you to generate one if you don't already have one

    You are not done yet ...

    2. You need to let your system know what key to use with which remote host, so add these lines to your ~/.ssh/config file

    Host bitbucket.org
     IdentityFile ~/.ssh/PRIVATE_KEY_FILE_NAME
    

    Where PRIVATE_KEY_FILE_NAME is the name of private part of your SSH key pair, if you haven't messed with it, usually its default name is : id_rsa in this case replace PRIVATE_KEY_FILE_NAME above with id_rsa(the private key DOES NOT have a .pub extension)

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

    If you want to clone open source projects to submit a Pull Request:

    I wanted to clone an open source project so I could submit some pull requests. The problem was that I didn't have permissions from the owner of the project. No matter, since my intention was to submit a PR, here is a viable alternative:

    My solution:

    1. Fork Repository

    1. Then clone from your forked repository.

    2. Work on your features and then submit a pull request.

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

    I see this errormessage has a lot of different reasons. I had the same error when trying to set up locally another repository alongside one already fully working with ssh etc. and connect it to same server, but other repository. No answers were here to be found, but I figured it out. So I post it. Hopefully helps someone.

    git remote add origin git@git.ourserver.com:teamalpha/repositorytwo.git
    
    0 讨论(0)
  • 2020-12-12 10:56

    Useful thread and I don't bring much new to the table. The step I took is also part of the description Maxime helpfully points to but some may overlook it. The section is Adding your SSH key to the ssh-agent.

    I had already generated my ssh-key but after a reboot I was unable to clone one of my own repositories.

    I had to start the ssh-agent and add the private key to this agent in order to clone.

    eval $(ssh-agent -s)
    ssh-add ~/.ssh/id_rsa
    
    0 讨论(0)
提交回复
热议问题