GitHub Error Message - Permission denied (publickey)

后端 未结 30 2176
长发绾君心
长发绾君心 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:21

    I found this page while searching for a solution to a similar error message using git pull on a remote host:

    $ git pull
    Permission denied (publickey).
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    

    I was connected from my local machine to the remote host via ssh -AY remote_hostname. This is not a solution to OP's question, but useful for others who come across this page, so posting it here.

    Note that in my case, git pull works fine on my local machine (that is, ssh key had been set up, and added to the GitHub account, etc). I solved my issue by adding this to ~/.ssh/config on my laptop:

    Host *
         ForwardAgent yes
    

    I then re-connected to the remote host with ssh -AY remote_hostname, and git pull now worked. The change in the config enables to forward my ssh keypair from my local machine to any host. The -A option to ssh actually forwards it in that ssh session. See more details here.

提交回复
热议问题