Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

reverse tunnel with automatic remote port selection

21 views
Skip to first unread message

philssh

unread,
Nov 13, 2009, 5:05:41 AM11/13/09
to
Hi,

I want to create a reverse tunnel with the -R option, but I don't want
to specify the port to be used on the remote server (because my client
application doesn't know which port is free on the server). So I
would like e.g. that ssh automatically selects a free port on the
server, possibly within a specified range.

Is there any way to do this with SSH?

If not, is there another common way to do this?

Thanks,
Phil

Jacob Nevins

unread,
Nov 13, 2009, 9:50:49 AM11/13/09
to

The SSH-2 protocol allows this (see RFC4254) -- when the forwarding it
set up, the client requests port 0, and the server responds to the
client telling it which port it chose.

However, many clients don't expose this -- I know PuTTY doesn't. OpenSSH
appears to have added it quite recently, in 5.2.
<https://bugzilla.mindrot.org/show_bug.cgi?id=1003>

There's a design problem with implementing this feature -- how should
the SSH client (or indeed the server) get the assigned port number to
someone who can use the information?
Looking at the bug above, it looks like the OpenSSH client just prints
it out. I haven't looked to see whether other implementations have dealt
with this problem.

0 new messages