multi-hop tunnel in the background; killing local tunnel does not kill remote tunnel
Run both ssh
-s locally. First connect to the jump server and create a tunnel that will allow you to ssh
to the remote host from the local computer:
ssh -fN $jump_host -l $jump_host_user -L ${helper_port}:${remote_host}:22
Then use this tunnel to connect to the remote host, creating the desired tunnel; still from the local computer:
ssh -fN localhost -p $helper_port -l ${remote_host_user} -L ${port}:localhost:${port}
Since the two ssh
processes are local, you can kill
them both whenever you like; but I think killing the first one should be enough, try it.
Notes:
- This approach may be inconvenient if your "secondary"
ssh
relies on specific config stored inssh_config
on the jump host. - I used lowercase variable names; see this answer.