从 EC2 实例克隆 git 存储库时遇到问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5998636/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Trouble cloning a git repository from an EC2 instance
提问by Rydell
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.
我正在尝试在 Amazon EC2 上运行的 ubuntu 服务器上放置一个裸 git 存储库。我遇到的困难是让 git 从我的本地电脑克隆存储库。
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 连接到同一台服务器上没有任何困难。例如,以下工作正常:
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.
我的想法是,如果这行得通,那么我就会在客户端和服务器上正确设置我的密钥。因此 git clone 命令也应该可以工作。
But no.
但不是。
I've researched and tried a number of variations, but I just have hunch I'm missing something brain dead simple.
我已经研究并尝试了许多变体,但我只是预感我错过了一些非常简单的东西。
回答by Seth Robertson
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.
检查以确保 git 正在执行您认为它正在执行的操作,然后尝试使用 git 用于联系远程服务器的确切命令。
Run GIT_TRACE=1 git clone [email protected]:/opt/git/project.git
跑 GIT_TRACE=1 git clone [email protected]:/opt/git/project.git
Git will tell you what command it is running, ex
Git 会告诉你它正在运行什么命令,例如
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:
然后,您可以尝试自己运行该命令以从图片中消除 git:
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.
如果还有问题,反馈上面显示的调试信息。
回答by Peter Hart-Davis
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.
有趣的。我在尝试从外部 GIT 源克隆到 EC2 主机时遇到了类似的问题。我使用上面的一些东西来工作。
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:
然后,我尝试更换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
I then ran the original git://
request and it worked.
然后我运行了原始git://
请求并且它起作用了。
I hope that helps.
我希望这有帮助。
回答by manojlds
The git account may not have read / write access to that repository/branch.
git 帐户可能没有对该存储库/分支的读/写访问权限。
回答by Jasper van den Bosch
Git uses port 9418. Is this open on your instance?
Git 使用端口 9418。这是在您的实例上打开的吗?
回答by respectTheCode
Try adding ssh:// to the remote address. I have never had good luck getting git to work consistently without it.
尝试将 ssh:// 添加到远程地址。没有它,我从来没有好运让 git 持续工作。
git clone ssh://[email protected]/opt/git/project.git
git clone ssh://[email protected]/opt/git/project.git