git push 返回“致命:协议错误:错误的行长度字符”

发布于 2024-09-09 08:11:50 字数 568 浏览 2 评论 0原文

我在我拥有的共享主机帐户上设置了一个远程 Git 存储库。为了允许另一个开发人员推送/拉取,我将他的公钥 (id_rsa.pub) 添加到共享主机上的 .ssh/authorized_keys 末尾。然后他就可以进行“git Push”了。但我想确保他除了访问 git 之外不能在我的共享主机上执行任何其他操作,因此我根据 manauthorized_keys

command="/usr/bin/git",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty ssh-rsa ...

现在,当他执行 git-push 时,它会在命令行上响应“致命:协议错误:错误的行长度字符”。

我通过 Google 进行了搜索,发现其他人也遇到此问题,但无法找到关于如何在不允许其他用户访问我的共享主机帐户上的 shell 的情况下解决此问题的充分答案。

I set up a remote Git repository on a shared host account I own. To allow another developer to push/pull, I added his public key (id_rsa.pub) to the end of .ssh/authorized_keys on the shared host. Then he was able to do "git push". But I want to make sure that he cannot do anything else on my shared host but access git, so I added this to the beginning of his entry in authorized_keys, according to man authorized_keys:

command="/usr/bin/git",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty ssh-rsa ...

Now when he does git-push, it responds on the command-line with "fatal: protocol error: bad line length character".

I've searched with Google, and found others having this problem, but could not find an adequate answer as to how to solve this without allowing this other user to have access to a shell on my shared host account.

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

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

发布评论

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

评论(2

纵性 2024-09-16 08:11:50

您需要限制其他开发人员的密钥运行 git-shell

command="/usr/bin/git-shell -c \"${SSH_ORIGINAL_COMMAND:-}\"",no-port-...

You need to limit the other developer's key to running git-shell as in

command="/usr/bin/git-shell -c \"${SSH_ORIGINAL_COMMAND:-}\"",no-port-...
悲喜皆因你 2024-09-16 08:11:50

检查您的 ~/.ssh/config 中是否有本地命令,例如

Host *
    LocalCommand echo 'Connected as "'%r'" to "'%h'"' ; echo 'SSH host "'%n'"'

如果有,请确保在使用 git 服务器时不要执行该命令。您可以通过仅针对所需主机覆盖 LocalCommand 来实现此目的:

Host *github*
    LocalCommand ''

Host *
    LocalCommand echo 'Connected as "'%r'" to "'%h'"' ; echo 'SSH host "'%n'"'

Check if you have a local command in your ~/.ssh/config such as

Host *
    LocalCommand echo 'Connected as "'%r'" to "'%h'"' ; echo 'SSH host "'%n'"'

If you do, make sure you don't execute that command when using git servers. You can do it by overriding the LocalCommand just for the desired hosts:

Host *github*
    LocalCommand ''

Host *
    LocalCommand echo 'Connected as "'%r'" to "'%h'"' ; echo 'SSH host "'%n'"'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文