Cannot push to git repository - permission denied

前端 未结 9 1001
太阳男子
太阳男子 2020-12-22 22:39

I have a following problem:

$ git push -u origin master
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you ha         


        
相关标签:
9条回答
  • 2020-12-22 23:14

    In my case I had this problem with GitLab because I was working with non-default SSH key pair paths. @NEO 's answer works perfectly:

    ssh-add ~/.ssh/other_id_rsa
    

    However, I had to do this everytime that I opened a new terminal.

    To make this change permanent, you have to edit ~/.ssh/config and add the following:

    Host gitlab.company.com
    RSAAuthentication yes
    IdentityFile ~/.ssh/config/private-key-filename
    

    For more detailed info check gitlab's documentation.

    0 讨论(0)
  • 2020-12-22 23:16

    If you haven't already read it, you should look through the GitHub help page for this error:

    Error: Permission denied (publickey)

    Every time that I've had this problem, it was due to the last issue listed on that page: I didn't have the public key from my current workstation attached to my GitHub account. Of course, GitHub also provides instructions on how to attach your public key to your account.


    tl;dr

    Make sure your current public key is attached to your GitHub account.

    0 讨论(0)
  • 2020-12-22 23:21

    I had the similar problem and my problem was solved by running the following command to add my key to the list of known keys:

    ssh-add ~/.ssh/id_rsa
    

    Hope it solves yours too. ;)

    0 讨论(0)
提交回复
热议问题