Question

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.

Était-ce utile?

La solution

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

Autres conseils

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'"'
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top