Cygwin/Git/Gitosis 无法推送新存储库

发布于 2024-08-10 10:06:03 字数 1000 浏览 9 评论 0原文

我最近在 Windows Server 2003 机器上设置了 cygwin、git 和 gitosis,但遇到了麻烦。我已经严格遵循了我能找到的所有教程,并确认当我推送 gitosis-admin 存储库时,我的 git 帐户的authorized_keys 表正在更新。然而,当涉及到创建新的存储库时,我似乎陷入了困境。

我看过很多推荐以下代码的教程(显然是存储库名称更改),在 git bash 和 windows 命令行中都进行了尝试:

mkdir free_monkey
cd free_monkey
git init
touch README
git add .
git commit -m "Added blank readme"
git remote add origin git@my_server:free_monkey.git
git push origin master

当我执行最后一行(无论我发送什么)时,它会显示“远程端意外挂断”: $ git push -v origin master:refs/heads/master 推送到 git@my_server:free_monkey.git 致命:远程端意外挂起

我的 gitosis.conf 文件如下所示:

[gitosis]
loglevel = DEBUG

[group gitosis-admin]
writable = gitosis-admin free_monkey.git free_monkey
members = git@my_server @all

如果我缺少任何您需要帮助我调试此问题的信息,请告诉我。谢谢你!

我关心的另一件事是:

$ ssh git@my_server git 
DEBUG:gitosis.serve.main:Got command 'git' 
ERROR:gitosis.serve.main:Unknown command denied 

这可能是问题所在吗?如果是这样,我该如何解决这个问题?

I've recently set up cygwin, git, and gitosis on my Windows Server 2003 box and am having troubles. I've followed just about every tutorial I can find to the letter, and have confirmed that my git account's authorized_keys table is getting updated when I push the gitosis-admin repository. I seem to be stuck, however, when it comes to creating a new repository.

I've seen many tutorials that recommend the following code (obviously the repo name changes), tried in both git bash and windows command line:

mkdir free_monkey
cd free_monkey
git init
touch README
git add .
git commit -m "Added blank readme"
git remote add origin git@my_server:free_monkey.git
git push origin master

When I execute the last line (no matter exactly what I send), it says "The remote end hung up unexpectedly":
$ git push -v origin master:refs/heads/master
Pushing to git@my_server:free_monkey.git
fatal: The remote end hung up unexpectedly

My gitosis.conf file looks like the following:

[gitosis]
loglevel = DEBUG

[group gitosis-admin]
writable = gitosis-admin free_monkey.git free_monkey
members = git@my_server @all

Please let me know if I'm missing any information you need to help me debug this. Thank you!

One other thing that concerns me:

$ ssh git@my_server git 
DEBUG:gitosis.serve.main:Got command 'git' 
ERROR:gitosis.serve.main:Unknown command denied 

Is that maybe the problem? If so, how do I fix that?

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

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

发布评论

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

评论(2

我一直都在从未离去 2024-08-17 10:06:03

您可能在第一次时犯了错字或其他原因。尝试删除原点并重新添加它:

git rm origin
git remote add origin git@my_server:free_monkey.git

然后再次尝试推送。值得一试。

You probably made a typo on the first time or something. Try removing the origin and re-adding it:

git rm origin
git remote add origin git@my_server:free_monkey.git

Then try pushing again. It's worth a try.

三生殊途 2024-08-17 10:06:03

好吧,看来“未知命令被拒绝”错误是一个转移注意力的事情。出于安全原因,Gitosis 只允许在 git 推/拉过程中实际发送的命令,因此“git”不是已知命令。

我继续收到相同的错误,但偶然发现另一个论坛中对authorized_keys文件的引用 - 拥有重复的密钥会完全破坏authorized_keys文件。果然,这是我的问题。希望这对那里的人有帮助。

要真正诊断此问题,请按照以下步骤操作:

  1. 为您用来访问 git 存储库的用户查找授权密钥文件(我的是 git@my_server,所以我查看了 /home/git/.ssh/authorized_keys)。确保每个公钥仅拥有一次。
  2. 我遇到了第二个问题,那就是我试图在 TortoiseGit 和 Pageant 中使用多个 ppk。 Pageant 似乎忽略了 TortoiseGit 更改密钥的请求;右键单击任务栏中的 Pageant(戴着帽子的计算机)并查看密钥,然后删除与您要使用的公钥不匹配的所有密钥(可能是全部)。

我现在可以通过 SSH 在我的服务器上运行 gitosis,可以通过 TortoiseGit 访问。

OK, so, it seems that the "Unknown command denied" error was a red herring. Gitosis only allows for the commands that actually get sent across during a git push/pull process for security reasons, so "git" was not a known command.

I continued receiving the same error, but stumbled-upon a reference to the authorized_keys file in another forum - having duplicate keys ruins the authorized_keys file completely. Sure enough, that was my problem. Hope this helps someone out there.

To really diagnose this, follow these steps:

  1. cat your authorized_keys files for the user you're using to access your git repositories (mine was git@my_server, so I looked in /home/git/.ssh/authorized_keys). Make sure you have each public key only once.
  2. I ran into a second problem, which was that I was trying to use multiple ppk's with TortoiseGit and Pageant. Pageant seems to ignore TortoiseGit's request to change keys; right click on Pageant in your taskbar (the computer wearing a hat) and View Keys, then remove all keys that don't match the public key you want to use (could be all of them).

I now have gitosis running on my server available over SSH, accessible via TortoiseGit.

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