I can clone a project as follows:
$ git clone [email protected]:root/myproject.git ~/bla
But now I wish to clone it to /var/www
. So I try
$ git clone [email protected]:root/myproject.git ~/var/www
But alas, I do not have permission to write to /var/www
. Sudo to the rescue!
$ sudo git clone [email protected]:root/myproject.git ~/var/www
Cloning into 'www'...
[email protected]'s password:
What's this? I am being asked for a password? We shouldn't need no stinking passwords!
I am obviously sending the root user's ssh keys with the request, and as they have not been imported to the git repository, I am being denied. In the past, my solution has been to temporarily change permissions of the folder or first clone it somewhere I have access and then move it using sudo, but would like to learn the right way to do so.
So... How do I use git with my normal user's ssh keys but sudo file permissions?