There are plenty of "recipes" out there that suggest using Netcat for
ProxyCommand with the
ssh program (either on the command line or in the
The entry in the configuration file usually looks as follows:
Host internal HostName internal ProxyCommand ssh gateway nc -w 10 %h %p 2> /dev/null
-w 10 being a timeout given to Netcat so that no stale instances of
nc remain once the SSH connection ends.
How can I achieve the same using
-L or a similar method, i.e. using the SSH client itself as the proxy command?
The following allows me to tunnel the connection to the host
internal to the local port 2222:
ssh -f -q -L 2222:internal:22 gateway sleep 10
... but how can I make this completely transparent for use in
ProxyCommand so as not to have to rely on
nc being installed? (above command obviously expects that someone make use of the tunnel on port 2222 within those 10 seconds specified in the
Note: in particular this has to be usable for unprivileged users as well.
Also note: my
ssh command doesn't support
-W, which apparently could act as one of the possible alternatives here.