Gitlab Permission denied (publickey) error SOLVED

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 git@gitlab.com: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 git@gitlab.com:your_account/user_repo.git

You can exclude git from git@gitlab.com also.

All done.. cloned the repo and did everything else without any problem.

DevSpace – Ubuntu 14.04 Vagrant Box for LAMP stack development environment

DevSpace Vagrant is a simple Ubuntu Trusty64 vagrant configuration for LAMP stack developers which also includes many related modern development tools.

Ubuntu 14.04 Vagrant Box – DevSpace

This vagrant use ubuntu/trusty64 from Atlas Vagrant Box. On your ‘vagrant up’ command, this vagrantfile will automatically download the box. Vagrant folder here contain a bootstrap.sh file which provision the vagrant box.

You need to place your projects in projects directory. This directory is synced with /var/www/htmldirectory in the virtual machine. This project folder also contain a config folder which is used during the provisioning.

This vagrant box is configured to use ‘1024mb’ of RAM and 1 Cpu. You can change ths configuration from Vagrantfile.

DevSpace Vagrant Installation

Install via Git

To use DevSpace vagrant, clone this github repo

$ git clone https://github.com/arifulhb/devspace.git

to your mac/pc/linux. When clone is complete, go to the `devspace` and now you are ready to use your Virtual Machine.

Use

Start the VM

$ cd /devspace
$ vagrant up

First time of your ‘vagrant up’ will provision the vagrant. You can see the status of your VM from http://192.168.33.10. You can check the `phpinfo` from http://192.168.33.10/phpinfo.php

List of Packages in DevSpace Vagrant

  • Apache2
  • PHP 5.6.7
  • MySQL 5.5.41
  • Git 1.9
  • Composer
  • Nodejs
  • NPM
  • Bower
  • Gulp

Requirements

You must have Vagrant and VirtualBox installed in your pc.

Default Credentials

These are credentials setup by default.

Host Address: – Hose: 192.168.33.10 (Change in Vagrantfile if you like)

SSH: vagrant / vagrant

MySQL: root/root
– Host: localhost
– Port: 3306

Fork and Tweet

This project is shared as Github Rep. If you find it helpful, you can Star and Fork in github. You can also help me to grow this project by tweet this.