Permission denied (publickey)
Seems a very common error in Gitlab.com or any Gitlab implementation. Last night I spend 4/5 hours without sleeping to solve the error.
Cloning into 'server'... Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. vagrant@advocado:/var/www/test/advo$ sudo git clone firstname.lastname@example.org:arifulhaque/server.git Cloning into 'server'... Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
This is not first time I am adding SSH Key to Gitlab. My other VM have it in 2 different gitlab implementations but this new VM is not working.
Before I get the error, I created a SSH Key and added the Public Key to Gitlab.com All worked fine, but I couldn’t clone any repo from account through ssh git.
I guess maybe I read almost all the solution over internet but none worked in my case. So, how did I finally solved this? Very Easy!
Step 1: Added a
config file in
~/.ssh/ folder which looks like
Host gitlab.com User git Hostname gitlab.com IdentityFile ~/.ssh/id_rsa_gitlab TCPKeepAlive yes IdentitiesOnly yes
Step 2: Just clone the git repo WITHOUT
git clone email@example.com:your_account/user_repo.git
You can exclude
All done.. cloned the repo and did everything else without any problem.