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?

2
  • 3
    There is no such thing. What is the problem you are trying to solve? Commented Dec 26, 2014 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" Commented Dec 27, 2014 at 1:42

2 Answers 2

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.

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.