Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to get round a silly firewall issue. I am trying to chain ssh access to git through a proxy ssh:


ssh hosticangetto ssh $*
# End

And then:

$ export GIT_SSH=~/git-chain
$ git clone ssh://

E, [2012-02-07T12:50:21.434913 #28359] ERROR -- : git command not recognized
fatal: The remote end hung up unexpectedly

the arguments being passed into my script are: git-upload-pack 'somerepo.git'

I've checked the keys from the hosticangetto to the git repository store and everything is ok.

I am not sure why this fails. I've done this sort of thing with mercurial before with mercurial -e switch.

share|improve this question

Add these lines to your ~/.ssh/config (or create that file with these lines if it doesn't already exist):

    ProxyCommand ssh -W %h:%p hosticangetto

Then unset GIT_SSH.

This tells ssh to ssh using hosticangetto as a proxy. This is better than your solution because in your solution, the packets are decrypted on hosticangetto and then re-encrypted for on the remote host. Using a proxycommand like this means that packets are encrypted for on your local machine and these encrypted packets are passed through hosticangetto.

share|improve this answer
using ssh proxies does work... but GIT_SSH should work too. Anyway, you're right. Proxy does work. – nic ferrier Feb 7 '12 at 16:02

I think you need to do something with the TTY.

This didn't work:

ssh server1 ssh server2

It just hangs there.

This seems to have worked:

ssh -t server1 ssh server2

Looking at the verbose output with ssh -v server1 ssh server2 it looks like the first/outside ssh completes and I get to server1, but I do not execute the inside/second ssh for server2.

share|improve this answer
No, I don't think so. chained ssh works fine. I'm not sure what issue you're seeing. I've tried adding tty switches and it makes no difference. It would be pretty wierd if git required a tty to operate. – nic ferrier Feb 7 '12 at 15:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.