To resolve the "Permission denied (publickey)" error when trying to clone a Git repository on Windows, follow these steps:
-
Verify Existing SSH Keys:
- Open Git Bash.
- Navigate to the SSH directory:
cd ~/.ssh
- List the files:
ls
- Look for
id_rsa
andid_rsa.pub
. If they are absent, you need to generate a new SSH key.
-
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.
- Run the following command, replacing your email:
-
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
- Start the SSH agent:
-
Copy Your Public Key:
- Display the public key:
cat ~/.ssh/id_rsa.pub
- Copy its contents.
- Display the public key:
-
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 SSH Connection:
- Run this command to test if your key is working correctly:
ssh -T [email protected]
- You should see a success message if configured correctly.
- Run this command to test if your key is working correctly:
- 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
- Now attempt to clone your repository again with:
If you follow these steps, you should be able to resolve the "Permission denied (publickey)" error and successfully clone your repository.