我正在尝试在Amazon EC2上运行的ubuntu服务器上放置一个裸git存储库。我遇到的困难是从我的本地电脑克隆存储库。
当我尝试:
git clone git@ec2-blah.compute-1.amazonaws.com:/opt/git/project.git
我明白了:
Cloning into project...
Unable to open connection:
Host does not existfatal: The remote end hung up unexpectedly
然而,我没有任何困难ssh'ing到同一台服务器。例如,以下工作正常:
ssh git@ec2-blah.compute-1.amazonaws.com
我的想法是,如果这是有效的,那么我会在客户端和服务器上正确设置我的密钥。因此git clone命令也应该可以工作。
但不。
我已经研究并尝试了很多变化,但我只是预感到我错过了一些脑死亡的东西。
答案 0 :(得分:8)
检查以确保git正在执行您认为正在执行的操作,然后尝试使用git用于联系远程服务器的确切命令。
运行GIT_TRACE=1 git clone git@ec2-blah.compute-1.amazonaws.com:/opt/git/project.git
Git会告诉你它正在运行什么命令,ex
trace: run_command: 'ssh' 'git@ec2-blah.compute-1.amazonaws.com' 'git-upload-pack '\''/opt/git/project.git'\'''
然后你可以尝试自己运行该命令以消除图片中的git:
ssh git@ec2-blah.compute-1.amazonaws.com git-upload-pack '/opt/git/project.git'
虽然根据您报告的错误消息似乎不太可能,但是支持该命令也可以提供提示:
strace -o/tmp/tr -s128 -f ssh git@ec2-blah.compute-1.amazonaws.com git-upload-pack '/opt/git/project.git'
如果仍有问题,请回复上面显示的调试信息。
答案 1 :(得分:2)
有趣。我尝试从外部GIT源克隆到EC2主机时遇到了类似的问题。我使用上面的一些东西工作了。
它失败了:
[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)
然后我尝试用git://
替换ssh://
并获得:
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
然后我运行了原始git://
请求并且它有效。
我希望有所帮助。
答案 2 :(得分:0)
git帐户可能没有对该存储库/分支的读/写访问权限。
答案 3 :(得分:0)
Git使用端口9418.你的实例是否打开了?
答案 4 :(得分:0)
尝试将ssh://添加到远程地址。如果没有它,我一直没有好运让git一直工作。
git clone ssh://git@ec2-blah.compute-1.amazonaws.com/opt/git/project.git