无法从EC2实例克隆git存储库

Ryd*_*ell 6 git amazon-ec2

我正在尝试在Amazon EC2上运行的ubuntu服务器上放置一个裸git存储库.我遇到的困难是从我的本地电脑克隆存储库.

当我尝试:

git clone git@ec2-blah.compute-1.amazonaws.com:/opt/git/project.git
Run Code Online (Sandbox Code Playgroud)

我明白了:

Cloning into project...
Unable to open connection:
Host does not existfatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

然而,我没有任何困难ssh'ing到同一台服务器.例如,以下工作正常:

ssh git@ec2-blah.compute-1.amazonaws.com
Run Code Online (Sandbox Code Playgroud)

我的想法是,如果这是有效的,那么我可以在客户端和服务器上正确设置我的密钥.因此git clone命令也应该可以工作.

但不是.

我已经研究并尝试了很多变化,但我只是预感到我错过了一些脑死亡的东西.

Set*_*son 8

检查以确保git正在执行您认为正在执行的操作,然后尝试使用git用于联系远程服务器的确切命令.

GIT_TRACE=1 git clone git@ec2-blah.compute-1.amazonaws.com:/opt/git/project.git

Git会告诉你它正在运行什么命令,例如

trace: run_command: 'ssh' 'git@ec2-blah.compute-1.amazonaws.com' 'git-upload-pack '\''/opt/git/project.git'\'''
Run Code Online (Sandbox Code Playgroud)

然后,您可以尝试自己运行该命令以消除图片中的git:

ssh git@ec2-blah.compute-1.amazonaws.com git-upload-pack '/opt/git/project.git'
Run Code Online (Sandbox Code Playgroud)

虽然根据您报告的错误消息似乎不太可能,但是对该命令进行支持也可以提供提示:

strace -o/tmp/tr -s128 -f ssh git@ec2-blah.compute-1.amazonaws.com git-upload-pack '/opt/git/project.git'
Run Code Online (Sandbox Code Playgroud)

如果仍有问题,请报告上面显示的调试信息.