git push 返回“致命:协议错误:错误的行长度字符”
我在我拥有的共享主机帐户上设置了一个远程 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要限制其他开发人员的密钥运行
git-shell
如You need to limit the other developer's key to running
git-shell
as in检查您的
~/.ssh/config
中是否有本地命令,例如如果有,请确保在使用 git 服务器时不要执行该命令。您可以通过仅针对所需主机覆盖
LocalCommand
来实现此目的:Check if you have a local command in your
~/.ssh/config
such asIf 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: