4
2
Why with ssh -R
is possible to allocate a free port by specifying '0' while with ssh -L
you need to specify a valid free port?
I want ssh to use a local free port to FWD remote traffic without depending on free ports hacks
From manual pages
-R [bind_address:]port:host:hostport
If the port argument is ‘0’, the listen port will be dynamically allocated on the server and reported to the client at run time.
But -L doesn't provide that possibility :(
-L [bind_address:]port:host:hostport
Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.....
Both the -L and -R ports are listening so your reply doesn't really make sense does it? – pedz – 2017-04-23T17:37:42.737
@pedz A local process will never listen to a remote machine port... – Dan Cornilescu – 2017-04-24T02:27:15.213
With the -R, the remote side does the listen. That is the difference between -R and -L. -L the local side listens. -R the remote side listens. In both cases, the port (if the options allowed it) could be specified or allowed to pick a ephermeral port. – pedz – 2017-05-06T13:10:15.597
Ah, I see what you mean - yes, technically they all listen for packets. I'll update the answer. – Dan Cornilescu – 2017-05-06T13:41:31.643