Reputation: 59576
I am connecting from a Ubuntu laptop to a virtual machine via ssh.
Within this VM, I am trying to git clone a repository with:
/home/httpd$ sudo git clone [email protected]:NexwayGroup/softgallery
[sudo] password for jverstrynge:
Cloning into 'softgallery'...
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
I have seen this SO question and the solution suggests modifying the git config with:
/home/httpd$ git config http.postBuffer 524288000
error: could not lock config file .git/config: No such file or directory
But I am getting the above error. Anyone knows how to solve this one?
I have checked the connection using github instructions and it seems fine:
ssh -T [email protected]
Warning: Permanently added the RSA host key for IP address '192.30.252.129' to the list of known hosts.
Enter passphrase for key '/home/jverstrynge/.ssh/id_rsa':
Hi JVerstry! You've successfully authenticated, but GitHub does not provide shell access.
jverstrynge@devjverstrynge:/home/httpd$
Upvotes: 3
Views: 4513
Reputation: 18869
One possible solution would be to setup your git host in ~/.ssh/config of the root user and use the ssh key from your user which has the git public, private key. A bit hacky, but should work.
Thus, add the following to /root/.ssh/config
:
Host github.com
Hostname github.com
User jverstrynge
IdentityFile /home/jverstrynge/.ssh/id_rsa
and then you should be able to do a sudo git clone [email protected]:NexwayGroup/softgallery
since the sudo should cause root user's .ssh/config to be used
Upvotes: 1
Reputation: 3649
You are running
sudo git clone
sudo runs the command as root, but your root probably does not have your private SSH key. Therefore, the connection can't be established.
A solution would be to either run the git command as your normal user (without sudo) or, if sudo is really needed for some reason, add the SSH key for root, too.
Upvotes: 4