Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission denied on git clone of my own private repo on a remote server - even though I added a new public key and all

Tags:

git

github

ssh

I have been setting up an instance of a server (Amazon EC2, Ubuntu 12.x), and have got stuck trying to clone my own private repo from git.

I've been looking at https://help.github.com/articles/generating-ssh-keys and https://help.github.com/articles/error-permission-denied-publickey for a while, but still no good.

I have generated a new ssh key pair on the remote machine with

ssh-keygen -t rsa -C "[email protected]"

and set up my git config fine, and I have added the public key to my github account. The email address is the same as the one I use on my local machine's ssh key (I don't know if that matters).

After starting an ssh-agent and then doing ssh-add -l, I get a fingerprint result that matches what is said in my github public key. ssh -T [email protected] also tells me that I have successfully authenticated.

However, whenever I try

git clone https://github.com/dmonopoly/myprivateproject.git

or

git clone [email protected]:dmonopoly/myprivateproject.git

on the remote machine (which I have sshed into), I get this error:

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

Ideas? I've handled the permission denied (public key) before, but this seems different. Help appreciated.

like image 287
dmonopoly Avatar asked Jan 14 '13 06:01

dmonopoly


People also ask

How do I fix Git permission denied?

In terminal enter this command with your ssh file name pbcopy < ~/. ssh/id_rsa. pub This will copy the file to your clipboard Now open you github account Go to Settings > SSH and GPG keys > New SSH key Enter title and paste the key from clipboard and save it. Voila you're done.

How do I fix public Permission denied permission?

If you want to use a password to access the SSH server, a solution for fixing the Permission denied error is to enable password login in the sshd_config file. In the file, find the PasswordAuthentication line and make sure it ends with yes . Find the ChallengeResponseAuthentication option and disable it by adding no .

How do I fix error permission denied Publickey fatal could not read from remote repository GitHub?

The “Permission denied (publickey). fatal: Could not read from remote repository” error is caused by an issue with the way in which you authenticate with a Git repository. To solve this error, make sure your key is being used on your Git account. If it is not, add your key to Git.


1 Answers

fatal: could not create work tree dir 'myprivateproject'.: Permission denied
                 ^^^^^^^^^^^^^^^^^^^^

That has nothing at all to do with access to the repository. You are trying to clone it to a directory where you don't have write access. Check permissions on the machine running git clone.

like image 88
Jan Hudec Avatar answered Sep 24 '22 03:09

Jan Hudec