简体   繁体   English

克隆远程git存储库问题

[英]Clone remote git repository problem

I am trying to get a git repository up and running and installed git and gitosis on my remote ubuntu 8.04 server. 我试图在我的远程ubuntu 8.04服务器上启动并运行git存储库并安装git和gitosis。 I also have git running on my local ubuntu 10.04 machine. 我也在本地ubuntu 10.04机器上运行git。

After alot of trying to get it all to work I managed to get the ssh keys to work. 在尝试使所有功能正常工作之后,我设法使ssh密钥正常工作。 When I type: 当我输入:

ssh git@myserver.com ssh git@myserver.com

it returns: 它返回:

PTY allocation request failed on channel 0 PTY分配请求在通道0上失败

ERROR:gitosis.serve.main:Need SSH_ORIGINAL_COMMAND in envirement. 错误:gitosis.serve.main:环境中需要SSH_ORIGINAL_COMMAND。

Connection to 123.456.789.1 closed. 与123.456.789.1的连接已关闭。

As far as I understand this means I succesfully connected to the server and the ssh key got accepted, but because it didn't get any commands it closes te connection. 据我了解,这意味着我已成功连接到服务器并且ssh密钥被接受,但是因为它没有收到任何命令,所以它关闭了连接。

When I try to get the repo: 当我尝试获取仓库时:

sudo git clone git@myserver.com:gitosis-admin.git 须藤git clone git@myserver.com:gitosis-admin.git

It returns: 它返回:

Initialized empty Git repository in /home/git/repositories/gitosis-admin/.git/ 在/home/git/repositories/gitosis-admin/.git/中初始化了空的Git存储库

git@myserver.com's password: git@myserver.com的密码:

The problem is, I don't have a password or phrase set, nor does it accept an empty password or the server password or my local's machine password. 问题是,我没有设置密码或短语,也不接受空密码或服务器密码或本地计算机的密码。 I understand it should'nt at all ask for a password because it should accept the ssh key (without a passphrase) and start downloading. 我了解它根本不要求输入密码,因为它应该接受ssh密钥(无密码)并开始下载。

From this pointon I have no idea how to get the remote repo to my local machine so I can start using git. 从这一点开始,我不知道如何将远程存储库获取到本地计算机,因此可以开始使用git。 I hope someone can point me in the right direction. 我希望有人能指出我正确的方向。

The authentication worked in your first test ( ssh git@server ). 身份验证在您的第一个测试( ssh git@server )中起作用。 If authentication had failed (or stalled with a prompt) you would never have seen a message from gitosis . 如果身份验证失败(或由于提示而停滞),您将永远不会看到gitosis发出的消息。 The warning and error you reported are to be expected when you try to do a normal, non-command ssh instead of letting git use ssh internally. 当您尝试执行普通的非命令ssh而不是让git在内部使用ssh时,应该会收到报告的警告和错误。

However, you did your clone in a slightly different environment (under sudo ). 但是,您是在稍微不同的环境中(在sudo下)进行克隆的。 The problem is probably that the ssh under sudo is not using the private key that the non- sudo , test ssh was using. 问题可能是sudo下的ssh未使用非sudo测试ssh使用的私钥。 In my testing, sudo ssh always uses files from ~root/.ssh , even if HOME points to a normal user's home directory. 在我的测试中, sudo ssh始终使用~root/.ssh文件,即使HOME指向普通用户的主目录也是如此。

Solutions: 解决方案:

  • Forego the use of sudo for cloning the repository. 放弃使用sudo克隆存储库。
  • Generate another SSH key-pair as root and add its public component to your gitosis configuration. 以根身份生成另一个SSH密钥对,并将其公共组件添加到gitosis配置中。

There is one other way, but it is an ugly one; 还有另一种方法,但这是丑陋的。 I will only leave a hint about it because it seems like such a bad idea to me. 我只会对此有所提示,因为对我来说这似乎是一个坏主意。 You could have root abuse its power to read the other user's private key file (you would still have to type the passphrase if it has one). 您可能会滥用root权限来读取另一个用户的私钥文件(如果有密码,则仍然必须键入该密码)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM