Skip to content

Instantly share code, notes, and snippets.

@vishnumitraha
Last active October 11, 2024 09:50
Show Gist options
  • Save vishnumitraha/f979bcec0f9eab14349c339650d32dc0 to your computer and use it in GitHub Desktop.
Save vishnumitraha/f979bcec0f9eab14349c339650d32dc0 to your computer and use it in GitHub Desktop.
SSH Key - Gitlab

To resolve the "Permission denied (publickey)" error when trying to clone a Git repository on Windows, follow these steps:

Check SSH Key Configuration

  1. Verify Existing SSH Keys:

    • Open Git Bash.
    • Navigate to the SSH directory:
      cd ~/.ssh
    • List the files:
      ls
    • Look for id_rsa and id_rsa.pub. If they are absent, you need to generate a new SSH key.
  2. Generate a New SSH Key (if necessary):

    • Run the following command, replacing your email:
      ssh-keygen -t rsa -b 4096 -C "[email protected]"
    • Press Enter to accept the default file location and set a passphrase if desired.
  3. Add Your SSH Key to the SSH Agent:

    • Start the SSH agent:
      eval "$(ssh-agent -s)"
    • Add your SSH private key:
      ssh-add ~/.ssh/id_rsa

Add Your Public Key to the Remote Repository

  1. Copy Your Public Key:

    • Display the public key:
      cat ~/.ssh/id_rsa.pub
    • Copy its contents.
  2. Add the Public Key to Your Git Server:

    • Log in to your Git server (e.g., code.cmcvellore.edu.in).
    • Navigate to your account settings and find the section for SSH keys.
    • Paste your public key and save it.

Test Your Connection

  1. Test SSH Connection:
    • Run this command to test if your key is working correctly:
    • You should see a success message if configured correctly.

Retry Cloning

  1. Clone the Repository Again:
    • Now attempt to clone your repository again with:
      git clone [email protected]:cap/student.git -b Test_Student_PWA_Webpack's

If you follow these steps, you should be able to resolve the "Permission denied (publickey)" error and successfully clone your repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment