Trouble cloning a git repository from an EC2 instance
Solution 1
Check to make sure git is doing what you think it is doing, and then try the exact command git is using to contact the remote server.
Run GIT_TRACE=1 git clone [email protected]:/opt/git/project.git
Git will tell you what command it is running, ex
trace: run_command: 'ssh' '[email protected]' 'git-upload-pack '\''/opt/git/project.git'\'''
You can then try to run that command yourself to eliminate git from the picture:
ssh [email protected] git-upload-pack '/opt/git/project.git'
While it seems unlikely given your reported error message, stracing the command can also provide hints:
strace -o/tmp/tr -s128 -f ssh [email protected] git-upload-pack '/opt/git/project.git'
Report back the debugging information revealed above if there are still problems.
Solution 2
Interesting. I was having a similar problem trying to clone from an external GIT source to an EC2 host. I got things working using some of the above.
It had been failing with:
[ec2-user@*.*.*. mediagoblin]$ sudo git clone git://gitorious.org/mediagoblin/mediagoblin.git
Cloning into mediagoblin...
gitorious.org[0: 87.238.52.168]: errno=Connection timed out
gitorious.org[0: 2a02:c0:1014::1]: errno=Network is unreachable
fatal: unable to connect a socket (Network is unreachable)
I then tried replacing git://
with ssh://
and got:
sudo git clone ssh://gitorious.org/mediagoblin/mediagoblin.git
Cloning into mediagoblin...
The authenticity of host 'gitorious.org (87.238.52.168)' can't be established.
RSA key fingerprint is *:*:*:*:*:**:.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitorious.org,87.238.52.168' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
I then ran the original git://
request and it worked.
I hope that helps.
sumeet
Updated on June 25, 2022Comments
-
sumeet almost 2 years
I'm attempting to put a bare git repository on a ubuntu server running on Amazon EC2. The difficulty I'm having is getting git to clone the repository from my local pc.
When I try:
git clone [email protected]:/opt/git/project.git
I get:
Cloning into project... Unable to open connection: Host does not existfatal: The remote end hung up unexpectedly
Yet I don't have any difficulty ssh'ing into the same server. For example the following works fine:
ssh [email protected]
My thinking was that if this is working, then I have my keys set up appropriately on the client, and on the server. Therefore the git clone command should work as well.
But no.
I've researched and tried a number of variations, but I just have hunch I'm missing something brain dead simple.
-
sumeet almost 13 yearsIn process of trying your suggestion. But do you need more than read access for a clone?
-
sumeet almost 13 yearsReally? I thought that git worked over the ssh protocol (port 22), which is what I was attempting to do. I have ports 80 and 22 open. I'm not using a git server (gitosis?).
-
manojlds almost 13 yearsOnly git protocol / git daemon is 9418
-
sumeet almost 13 yearsThanks for the debug help. It gave me a few ideas. I can't explain why, but the upgrading my version of msysgit 1.7.3.1 preview to 1.7.4 preview seemed to solve the problem. I was hoping for something clearer than that, but there you have it.