How can I establish a reverse ssh tunnel with my ./ssh/config file?
I'm trying to reproduce this command
ssh [email protected] -L 4444:restricedserver1.org:4420 -L 4445:restricedserver2:4430
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityHow can I establish a reverse ssh tunnel with my ./ssh/config file?
I'm trying to reproduce this command
ssh [email protected] -L 4444:restricedserver1.org:4420 -L 4445:restricedserver2:4430
Yes. The option is called RemoteForward
with a bit different syntax.
But in your example, you are using LocalForward
, which would look like this in ssh_config
:
Host dmx.com
User admin
LocalForward 4444 restricedserver1.org:4420
LocalForward 4445 restricedserver2:4430
You don't need a tunnel. Use ProxyCommand
instead:
Host restricedserver1
HostName restricedserver1.org
User admin
Port 4420
ProxyCommand ssh -A -q -l %r -W %h:4444 dmx.com
ControlMaster auto
ControlPersist 5m
and similar for the other host. The advantage over a tunnel is that you don't need to keep it up all the time.