GitHub Error Message - Permission denied (publickey)

后端 未结 30 2093
长发绾君心
长发绾君心 2020-11-22 04:23

Anybody seen this error and know what to do?

I\'m using the terminal, I\'m in the root, the GitHub repository exists and I don\'t know what to do now.



        
相关标签:
30条回答
  • 2020-11-22 05:02

    This happened to me. For some reason my origin got messed up without my realizing it:

    Check if your settings are still correct

    git remote -v
    

    the url needs to be something like ssh://git@github.com/YourDirectory/YourProject.git; if you don't see git@github.com, use

    git remote set-url origin git://github.com/YourDirectory/YourProject.git
    

    to set it right. Or you could use the github app to check and set the Primary Remote Repository url in the settings panel of your particular repository.

    0 讨论(0)
  • 2020-11-22 05:02

    tl;dr

    in ~/.ssh/config put

    PubkeyAcceptedKeyTypes=+ssh-dss
    

    Scenario If you are using a version of openSSH > 7, like say on a touchbar MacBook Pro it is ssh -V
    OpenSSH_7.4p1, LibreSSL 2.5.0

    You also had an older Mac which originally had your key you put onto Github, it's possible that is using an id_dsa key. OpenSSH v7 doesn't put in by default the use of these DSA keys (which include this ssh-dss) , but you can still add it back by putting the following code into your ~/.ssh/config

    PubkeyAcceptedKeyTypes=+ssh-dss
    

    Source that worked for me is this Gentoo newsletter

    Now you can at least use GitHub and then fix your keys to RSA.

    0 讨论(0)
  • 2020-11-22 05:03

    Also in ubuntu, even though there was already SSH key entered in settings in BitBucket, I got this problem. The reason was, I was trying the following:

    sudo git push origin master
    

    Not sure why, but it got solved by using

    git push origin master
    

    No sudo used.

    0 讨论(0)
  • 2020-11-22 05:04

    I think i have the best answer for you, your git apps read your id_rsa.pub in root user directory

    /home/root/.ssh/id_rsa.pub
    

    That's why your key in /home/your_username/.ssh/id_rsa.pub can't be read by git. So you need to create the key in /home/root/.ssh/

    $ sudo su
    $ ssh-keygen
    $ cd ~/.ssh
    $ cat id_rsa.pub
    

    Then copy the key in your github account. It's worked for me. You can try it.

    0 讨论(0)
  • 2020-11-22 05:05

    I would like to add some of my findings:

    If you are using GitBash, then make sure the SSH key is stored in ~/.ssh/id_rsa.

    By Default GitBash searches for ~/.ssh/id_rsaas default path for SSH key.

    Even the file name id_rsa matters. If you save your SSH key in another filename or path, it will throw the Permission Denied(publickey)error.

    0 讨论(0)
  • 2020-11-22 05:05

    Maybe your ssh-agent is not enable You can try it

    1. Download git

    http://git-scm.com/

    1. Install it

    2. Enable ssh-agent

    C:\Program Files\Git\cmd

    start-ssh-agent

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