Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
923 views
in Technique[技术] by (71.8m points)

ssh - git push returns "fatal: protocol error: bad line length character"

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...