Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission denied when cloning git repository

So I just setup an Amazon EC2 instance. And installed git..

sudo yum install git

I then set up my ssh key with github. Now when I try to clone my repo into /var/www/html folder i get this error..

fatal: could not create work tree dir 'example.com'.: Permission denied

and when I run as root...

Cloning into 'example.com'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

But I made sure that my github public key matches my ~/.ssh/id_rsa.pub key. Is there something that I'm missing here?

like image 416
coryj Avatar asked Mar 29 '13 01:03

coryj


1 Answers

Your first error is because your user does not have access to write to /var/www/html . You could give your user permissions to do so.

Your second error when running as root, is likely that you have your ssh keys in your user home directory, not in /root/.ssh/ , or that your .ssh directory or the ~/.ssh/id_rsa.pub key file have improber permissions. ~/.ssh/ should have the permission bits 0700 , and should have ~/.ssh/id_rsa.pub e.g. 0600

like image 191
nos Avatar answered Sep 20 '22 22:09

nos