4 ms·
A challenge I've had with Autossh (and OpenSSH for that matter) is in getting the listen port during remote (reverse) tunnels when it is dynamically assigned vi
by tomkinstinch 11y ago
A challenge I've had with Autossh (and OpenSSH for that matter) is in getting the listen port during remote (reverse) tunnels when it is dynamically assigned via '-R 0:localhost:$SOMEPORT' where $SOMEPORT is on the machine originating the reverse tunnel, and 0 is a dynamically assigned open port on the relay/remote machine. It doesn't look like there is a good way[1] to get the listen port from the originating side (remotehost:$DYNPORT) without inspecting ssh stdout (complicated when using Autossh via systemd). Any ideas? On the remote side it is easy to find the listen port provided you have sudo access, but seemingly impossible without [2]. On the local side I probably just need to pipe stdout to a regex to find the right string and then redirect the captured port number to a file or named pipe, but it seems like it ought to be easier to get dynamic port assigned on the remote side from the local end of the tunnel.
1. http://www.nico.schottelius.org/blog/openssh-6.2-add-callback-functionality-using-dynamic-remote-port-forwarding/ http://www.nico.schottelius.org/blog/openssh-6.2-add-callbac...
2. https://gist.github.com/tomkinsc/c2932097796155f4fd94 https://gist.github.com/tomkinsc/c2932097796155f4fd94