设置 Gitosis,但无法克隆

发布于 2024-07-29 03:45:16 字数 904 浏览 8 评论 0原文

我已经在远程 Ubuntu 机器上设置了 Gitosis,在以下命令中我将其称为 linuxserver 作为我的主机。 我还使用 Cygwin 从 Windows 盒子进行连接。

我按照以下说明进行操作: http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way

在我需要克隆 gitosis-admin 之前我没有遇到任何问题 当我执行此操作时,命令会执行,但会挂在那里,

git clone git@linuxserver:gitosis-admin.git

不显示任何内容,直到我按 ctrl-c 返回命令提示符为止。 根本不显示任何消息。

我很确定我的 ssh 密钥设置正确,因为使用“ssh linuxserver”登录我的常规帐户可以完美地工作,无需输入密码。

编辑:周末我在家里设置了一个几乎相同的 Ubuntu 盒子,并且设置 Gitosis 没有任何问题。 唯一的区别是我是从 OSX 而不是 Cygwin 连接的。

编辑:我还发现,当使用“Git Extensions”提供的 Bash Shell 时,我没有任何问题,所以问题肯定是某种 Cygwin 冲突。

编辑:只是一个更新,但在发布这个问题大约一个月后,我切换到 Mercurial,发现我比 git 更喜欢它。 感谢您的建议,但我不打算返回 git 来尝试其中的任何建议。

I've set up Gitosis on a remote Ubuntu box which I will refer to as linuxserver as my host in the following commands. I'm also connecting from a Windows box using Cygwin.

I followed the instructions according to: http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way

I had no problems up until I needed to clone the gitosis-admin repository to my local machine

git clone git@linuxserver:gitosis-admin.git

When I do this, the command executes, but hangs there displaying nothing until I ctrl-c to get back to a command prompt. No messages are displayed at all.

I'm pretty sure I have my ssh keys set up properly, because logging in using "ssh linuxserver" into my regular account works perfectly without asking for a password.

Edit: Over the weekend I set up a near identical Ubuntu box at home, and had no problem setting up Gitosis. The only difference was that I was connecting from OSX instead of Cygwin.

Edit: I've also discovered that when using the Bash Shell provided with "Git Extensions", I have no problems, so the issue definitely seems to be some kind of Cygwin conflict.

Edit: Just an update, but about a month after posting this question, I switched to Mercurial, and found that I prefer it much more than git. Thanks for the suggestions, but I don't plan on going back to git to try any of them out.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

佼人 2024-08-05 03:45:16

我还建议在conf.d文件中设置调试选项。

[gitosis]
loglevel = DEBUG

I'd also recommend setting the debug option in the conf.

[gitosis]
loglevel = DEBUG
睡美人的小仙女 2024-08-05 03:45:16

您检查过服务器上的 /var/log/messages 吗?
可能是用户名“git”无法正常工作:来自 Gitosis 的注释

如果你查看authorized_key 文件,你会发现它没有导入生成密钥的系统的名称,而是导入了服务器框的名称。

示例:使用用户名“git”导致授权密钥中出现此情况

root@git-repo:/home/git/.ssh# cat authorized_keys command=”gitosis-serve root@git-repo”

更改为用户名“gitosis”后,它看起来像这样

root@git-repo:/home/gitosis/.ssh# cat authorized_keys command=”gitosis-serve myuser@mylocalbox”, 

要解决此问题,我创建了一个用户 gitosis,其主目录为 /home/gitosis 并运行了 git-init 脚本再次。

sudo -H -u gitosis gitosis-init < /tmp/id_rsa.pub
sudo chmod 755 /home/gitosis/repositories/gitosis-admin.git/hooks/post-update

然后,在本地盒子上..

git clone gitosis@YOUR_SERVER_HOSTNAME:gitosis-admin.git

Did you check /var/log/messages on your server?
May be the username 'git' does not work properly: From the comments of Gitosis,

if you look at the authorized_key file you will see that it did not import the name of the system that key was generated on but the name of the server box.

Example: using a username of “git” resulted in this in the authorized key

root@git-repo:/home/git/.ssh# cat authorized_keys command=”gitosis-serve root@git-repo”

After changing to user name “gitosis” it looks like this

root@git-repo:/home/gitosis/.ssh# cat authorized_keys command=”gitosis-serve myuser@mylocalbox”, 

To fix I created a user gitosis with home dir of /home/gitosis and ran the git-init script again.

sudo -H -u gitosis gitosis-init < /tmp/id_rsa.pub
sudo chmod 755 /home/gitosis/repositories/gitosis-admin.git/hooks/post-update

then, on local box..

git clone gitosis@YOUR_SERVER_HOSTNAME:gitosis-admin.git
小嗲 2024-08-05 03:45:16

我发现这些说明提供了有关安装 gitosis 时所做操作的更多说明。 可能会帮助某人。

I found these instructions provided more explanation of what you are doing when you install gitosis. Might help someone.

征棹 2024-08-05 03:45:16

我遇到了和你一样的问题,我的解决方案是将用户“git”添加到服务器上 ssh 配置文件中允许的用户中。 一个基本的疏忽 - 是的 - 但当我遵循相同的教程并且没有提到此步骤时,其他人很容易忘记将 git 用户添加到 ssh 配置文件中。

I had the same problem as you and my solution to the problem was to add the user "git" to the allowed users in the ssh config file on the server. A basic oversight - yes - but as I followed the same tutorial and this step is not mentioned it could easily be that other people forgot about adding the git user to the ssh config file.

牵你手 2024-08-05 03:45:16

我的电脑上也有类似的问题。 我在 Archlinux 上安装了 gitosis,它在运行时可以工作,

git clone ssh://git@localhost/oslab.git

但是如果我将 localhost 更改为 IP(如 192.168.1.1),它就会挂起。

I had similar problem on my computer. I installed gitosis on Archlinux and it works when running

git clone ssh://git@localhost/oslab.git

But if I change the localhost to IP like 192.168.1.1, it hangs.

仅冇旳回忆 2024-08-05 03:45:16

如果其他人遇到此问题,并且尝试从也安装了 Msys Git 的客户端上的 Cygwin 环境进行连接,请检查 GIT_SSH 环境变量的值。 它应该未设置或等于 /usr/bin/ssh 而不是 plink.exe

我能够以 git 用户身份 ssh 到服务器(预期会被 gitosis 脚本拒绝),但是我无法克隆。

我意识到发生了一些奇怪的事情,因为 git 仍然警告主机未知,而直接 ssh 连接却没有。 当我查看 strace 的输出

strace git clone git@server:gitosis-admin.git | less

并搜索字符串“ssh”时,这得到了证实,显示 GIT_SSH 指向 plink.exe - Msys Git 使用的 putty ssh 客户端。 不知道为什么 plink.exe 不起作用,但设置 GIT_SSH=/usr/bin/ssh 修复了问题。

If anyone else has had this problem, and was trying to connect from a Cygwin environment on a client that also had Msys Git installed, check the value of the GIT_SSH environment variable. It should be unset or equal to /usr/bin/ssh not plink.exe

I was able to ssh to the server as the git user (with the expected rejection from the gitosis scripts), however I was unable to clone.

I realised something strange was happening because git was still warning that the host was unknown whereas a direct ssh connection did not. This was confirmed when I looked in to the output from strace

strace git clone git@server:gitosis-admin.git | less

Searching for the sting "ssh", showed that GIT_SSH pointed to plink.exe - the putty ssh client used by Msys Git. Not sure why plink.exe didn't work, but setting GIT_SSH=/usr/bin/ssh fixed things.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文