[PATCH] Expose remote forwarding ports as environment variable
philipp.marek at linbit.com
Fri May 17 15:19:16 EST 2013
> At the server end, I want to connect to Alice's -R forwarding.
> I can't rely on Alice telling me which -R port she's connecting
> to, as she might tell me Bob's port. So I need to know which
> session is associated Alice using server side information only.
> I have a nasty hack which (in essence) involves making forceCommand
> run something server side which records the PID of sshd, looks
> at the table of listening sockets, sees what processes own them,
> and links up the two. This is pretty disgusting.
If you need a local TCP port, how about using socat to link it to SSH's
stdin/stdout, and (if needed) do the reverse on the server side?
Then there's no port actually forwarded (just the "normal" data flow),
so there won't (and can't) be any collisions, and you can simply
determine which port is _really_ in use.
More information about the openssh-unix-dev