Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

To ssh onto a box behind some firewall I can do the following

home$ ssh me@ssh-server
ssh-server$ ssh me@box-behind-firewall

So that I can do things like use git repos etc on box-behind-firewall from outside the network, I want to combine these into a single uri, e.g. something like


Is this possible, and how's it done?

share|improve this question

You probably want to use port forwarding. Connect the the first machine using

ssh -L2222:box-behind-firewall:22 me@ssh-server

While that connection is active, you can connect to the second machine using

ssh -p 2222 me@localhost

from you local machine or access git repositories on the server using


as URI.

share|improve this answer

This is not possible the way you want. You would need to execute some command after logging in which ssh-URI-scheme does not support - I guess due to security concerns.

If you could run a command, you could directly do an ssh to the next server while connecting.

But you can do it with some workaround. This line's from man sshd

8. If ~/.ssh/rc exists, runs it[...]

You could just add the ssh-command to the next server (or firewall/router) here. You just need to find some way to distinguish if you want to connect the "normal" way or want to be forwarded to the router - maybe you're able to just add an user on the first server which only has the purpose to forward you to the next server?

share|improve this answer

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.