3

I am looking for a way to redirect an ssh connection from one host to another. When a user creates an ssh connection to host foo, I would like the server to return some response which causes the ssh client to close the ssh connection to foo and instead connect to host bar.

Importantly, for the application I have in mind it is not okay to simply forward the ssh connection to bar via foo, so standard port forwarding is out of the question. Once the redirection occurs, the client should be sending TCP packets directly to bar, not to foo (and not to bar via foo).

So, roughly, I'm looking for an SSH analogue to an HTTP redirect (which causes the client to hang up the original connection and connect instead to the host to which it was redirected).

It is also important for the application I have in mind that this not require any client-side configuration.

So is it possible to do this?

  • 3
    There is no such thing. What is the problem you are trying to solve? – Michael Hampton Dec 26 '14 at 19:46
  • I have an SSH server running on some custom port (not 22) and I want to create a facade that will allow someone to "ssh foo.somehost.com" and have it resolve to "ssh -p XXXX www.somehost.com" – Alex Flint Dec 27 '14 at 1:42
4

There is no provision in the SSH protocol for redirects. Read RFC 4251, RFC 4252, and RFC 4253 for details of the connection negotiation.

| improve this answer | |
0

You can setup the foo SSH server to work as a kind of proxy to the bar SSH server.

For example with OpenSSH, you should be able to use ForceCommand to SSH to the bar server:

ForceCommand ssh bar_host

Of course the account on the foo host have to be configured to allow interaction-less access to the bar, e.g. by having unencrypted private key.

This will work transparently to the client application.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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