Determining dynamically allocated port on the server side

Vegard Svanberg vegard at svanberg.no
Mon Apr 6 23:06:59 AEST 2020


Hi,

I'm connecting multiple times from several clients to a server. I need
to be able to connect back from the server to the clients (which may be
behind NATs and firewalls), so I use forwarding (-R).

The sheer number of connections and sessions makes keeping track of port
numbers complicated. Hence I use port 0 to dynamically allocate.

However, I'm unable to find a proper/reliable way of determining the
port number on the server side. It's easy enough on the client side,
though, as it's reported to stderr there.

I found a patch[1] for 6.2, but it doesn't seem to have been included.

I DDG'd a bit, but didn't find (or didn't understand :-) ) any
straight-forward approaches. 

Any suggestions?

[1] https://www.nico.schottelius.org/blog/openssh-6.2-add-callback-functionality-using-dynamic-remote-port-forwarding/

-- 
Vegard Svanberg <vegard at svanberg.no> [*Takapa at IRC (EFnet)]



More information about the openssh-unix-dev mailing list