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 [email protected]: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! Solution
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 sudo.
git clone [email protected]:your_account/user_repo.git
source: http://www.arifulhaque.com/gitlab-permission-denied-publickey-error-solved/
Excellent, thanks !