GitHub: Permission denied (publickey). fatal: The remote end hung up unexpectedly

前端 未结 23 1553
情深已故
情深已故 2020-11-28 01:09

I have followed these instructions below to upload a project.

Global setup:

 Download and install Git
  git config --global user.name \"Your Name\"
         


        
相关标签:
23条回答
  • 2020-11-28 01:51

    For me, it worked like this:

    In GitHub I changed the ssh link to https, and then gave the following commands:

    $ git init
    $ git remote add origin https:...
    $ git add .
    $ git commit -m "first commit"
    $ git push origin master
    
    0 讨论(0)
  • 2020-11-28 01:52

    For me the problem was the execution of clone via sudo.

    If you clone to a directory where you have user permission ( /home/user/git) it will work fine.

    (Explanation: Running a command as superuser will not work with the same public key as running a command as user. Therefore Github refused the connection.)

    This solution requires a SSH key already to be set up: https://help.github.com/articles/generating-ssh-keys

    0 讨论(0)
  • 2020-11-28 01:53

    Given that none of the answers here worked for me, I finally tracked down my issue connecting to Bitbucket (or Github, doesn't matter in this case) with ssh -vT git@bitbucket.org.

    In my case, the failure was due to using a DSA key instead of RSA, and apparently my SSH client no longer allows that.

    debug1: Skipping ssh-dss key /c/Users/USER/.ssh/id_dsa for not in PubkeyAcceptedKeyTypes

    The solution was to add this to .ssh/config:

    Host *
        PubkeyAcceptedKeyTypes +ssh-dss
    

    This elegantly appends the ssh-dss key type to all existing accepted public key types and after this was done, git can now ssh into Bitbucket no problem.

    0 讨论(0)
  • 2020-11-28 01:54

    I got a solution after a long time in tutorials.

    I followed the github tutorial on this link -> https://help.github.com/articles/error-permission-denied-publickey and I was able to connect in every step. But when I was trying to git push -u origin master I got this error:

    Permission denied (publickey). fatal: Could not read from remote repository.

    Please make sure you have the correct access rights

    Thats how I`ve fixed it!! Go to the project directory using the Terminal and check it out

    $git remote -v
    

    You will get something like this:

    origin  ssh://git@github.com/yourGithubUserName/yourRepo.git (fetch)
    origin  ssh://git@github.com/yourGithubUserName/yourRepo.git (push)
    

    If you are using anything different then git@github.com, open the config file on git directory by typing the command:

    vi .git/config
    

    And configure the line

    [remote "origin"]
    
    url = ssh://git@github.com/yourGithubUserName/yourRepo.git
    
    fetch = +refs/heads/*:refs/remotes/origin/
    
    0 讨论(0)
  • 2020-11-28 01:55

    Yes, It's a public key Problem. I'm a windows user,and the page below help me resolve this problem.

    http://help.github.com/win-set-up-git/

    more precisely this link should be helpful

    https://help.github.com/articles/error-permission-denied-publickey

    0 讨论(0)
  • 2020-11-28 01:55

    My issue was that I was trying to give my ssh key a SPECIFIC NAME every time I entered ssh-keygen on my mac terminal.

    I solved the issue by just leaving the name that "ssh-keygen" generates = id_rsa. You'll end up with 2 keys in your .ssh folder on a mac, id_rsa, which is your private key, and the id_rsa.pub, which is your public key. Then I copied and saved the code from id_rsa.pub into my GitHub account settings, and that was it. Problem solved.

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