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

后端 未结 30 2264
野性不改
野性不改 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:36

    I was struggling with same problem that's what i did and i was able clone the repo. I followed these procedure for iMac.

    First Step : Checking if we already have the public SSH key.

    1. Open Terminal.
    2. Enter ls -al ~/.ssh to see if existing SSH keys are present:

    Check the directory listing to see if you already have a public SSH key.Default public are one of the following d_dsa.pub,id_ecdsa.pub,id_ed25519.pub,id_rsa.pub

    If you don't find then go to step 2 otherwise follow step 3

    Step 2 : Generating public SSH key

    1. Open Terminal.
    2. Enter followong command with you valid email address that you use for github ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
    3. You will see following in terminal Generating public/private rsa key pair. When it prompts to"Enter a file in which to save the key," press Enter. This accepts the default file location. When it prompts to Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter] Just press enter again. At the prompt, type a secure passphrase.
    4. Enter passphrase (empty for no passphrase): [Type a passphrase] press enter if you don't want to Enter same passphrase again: [Type passphrase again] press enter again

    This will generate id_rsa.pub

    Step 3: Adding your SSH key to the ssh-agent

    1. Interminal type eval "$(ssh-agent -s)"
    2. Add your SSH key to the ssh-agent. If you are using an existing SSH key rather than generating a new SSH key, you'll need to replace id_rsa in the command with the name of your existing private key file. Enter this command $ ssh-add -K ~/.ssh/id_rsa

    Now copy the SSH key and also add it to you github account

    1. In terminal enter this command with your ssh file name pbcopy < ~/.ssh/id_rsa.pub This will copy the file to your clipboard Now open you github account Go to Settings > SSH and GPG keys > New SSH key Enter title and paste the key from clipboard and save it. Voila you're done.

提交回复
热议问题