Vegard Svanberg
2020-Apr-06 13:06 UTC
Determining dynamically allocated port on the server side
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)]