How to solve Permission denied (publickey) error when using Git?

后端 未结 30 1840
野性不改
野性不改 2020-11-22 08:07

I\'m on Mac Snow Leopard and I just installed git.

I just tried

git clone git@thechaw.com:cakebook.git

but that gives

相关标签:
30条回答
  • 2020-11-22 08:17

    These are the steps I followed in windows 10

    1. Open Git Bash.

    2. Generate Public Key:

      ssh-keygen -t rsa -b 4096 -C "youremailaddress@xyz.com"
      
    3. Copy generated key to the clipboard (works like CTRL+C)

      clip < ~/.ssh/id_rsa.pub
      
    4. Browser, go to Github => Profile=> Settings => SSH and GPG keys => Add Key

    5. Provide the key name and paste clipboard (CTRL+V).

    6. Finally, test your connection (Git bash)

      ssh -T git@github.com
      

    Thanks!

    0 讨论(0)
  • 2020-11-22 08:19

    I was getting a similar Permission denied (publickey) error when trying to run a makefile.

    As an alternative to the SSH steps above, you can Install the native GitHub for Mac application.

    Click Download GitHub for Mac from - https://help.github.com/articles/set-up-git#platform-mac

    Once you complete setup with your git hub account (I also installed the git hub command line tools but unsure if this step is required or not) then I received an email -

    [GitHub] A new public key was added to your account

    and my error was fixed.

    0 讨论(0)
  • 2020-11-22 08:20

    In addition to Rufinus' reply, the shortcut to copy your ssh key to the clipboard in Windows is:

    • type id_rsa.pub | clip

    Refs:

    • Print to standard output
    • Copy command line output to clipboard
    0 讨论(0)
  • 2020-11-22 08:21

    The basic GIT instructions did not make a reference to the SSH key stuff. Following some of the links above, I found a git help page that explains, step-by-step, exactly how to do this for various operating systems (the link will detect your OS and redirect, accordingly):

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

    It walks through everything needed for GITHub and also gives detailed explanations such as "why add a passphrase when creating an RSA key." I figured I'd post it, in case it helps someone else...

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

    Its pretty straight forward. Type the below command

    ssh-keygen -t rsa -b 4096 -C "youremailid@yourdomain.com"
    

    Generate the SSH key. Open the file and copy the contents. Go to GitHub setting page , and click on SSH key . Click on Add new SSH key, and paste the contents here. That's it :) You shouldn't see the issue again.

    0 讨论(0)
  • 2020-11-22 08:23

    On Windows, make sure all your apps agree on HOME. Msys will surprisingly NOT do it for you. I had to set an environment variable because ssh and git couldn't seem to agree on where my .ssh directory was.

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