Reputation: 391
When trying to clone git account from gitlab using,
git clone [email protected]:username/project.git
facing the below error,
[email protected]: Permission denied (publickey). fatal: Could not read from remote repository.
The gitlab is registerd with my custom.pub public ssh key. Both the private and public ssh key of the windows client PC is stored in "C:/Users/username/.ssh".
How to fix this failure
Upvotes: 2
Views: 7787
Reputation: 391
This answer for Windows. Should also apply to Linux machines with some modifications.
Since the ssh key was created with custom name 'custom.pub', ssh is unable to use that key. It instead by default looks for 'id_ecdsa'/'id_rsa' named key files. Here are the steps to fix such authentication errors,
Open .ssh/config file and make following changes,
Host *gitlab.com
IdentityFile <your_custom_key_path>/custom_key
Upvotes: 8