git push returns “fatal: protocol error: bad line length character”

我与影子孤独终老i 提交于 2019-11-28 11:02:56

问题


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.


回答1:


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-...



回答2:


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'"'


来源:https://stackoverflow.com/questions/3224340/git-push-returns-fatal-protocol-error-bad-line-length-character

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!