how to check whether the ssh tunnel is up

Damien Miller djm at
Sat Apr 27 16:19:22 EST 2013

On Fri, 26 Apr 2013, Vincent Lin wrote:

> Hi all,
> I use the command below to set up a ssh tunnel. And I run it as a daemon
> process to keep the ssh tunnel work all the time. And I should wait for the
> ssh tunnel to be up and notify the tunnel is OK before sending any command
> to the remote port on the remote server. But the question is I don't know
> how to check the ssh tunnel status. Is there a way to show whether the ssh
> tunnel is up?  Thank you for your help.
> *"ssh -i /root/ah_rsa -oUserKnownHostsFile=/root/hosts
> -oStrictHostKeyChecking=yes -oNumberOfPasswordPrompts=0 -oBatchMode=yes
> -oHostKeyAlgorithms=ssh-rsa -R 20001:localhost:22 user at -p
> 13422 -Nyv"*

ExitOnForwardFailure=yes should provide the checking you need. If you use
it with -f then the fork is delayed until the forwarding is answered by
the server, though note that this doesn't include an end-to-end test that
involves the forward target - that is till up to you to check if you need it.


More information about the openssh-unix-dev mailing list