how to check whether the ssh tunnel is up

Daniel Kahn Gillmor dkg at fifthhorseman.net
Sat Apr 27 16:22:50 EST 2013


On 04/26/2013 05:06 PM, Vincent Lin wrote:

> 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.

I recommend using -oExitOnForwardFailure=yes in such a configuration.

You could also look into the various keepalive options (TCPKeepAlive,
ServerAliveCountMax, ServerAliveInterval) to ensure that your process
terminates when the connection is no longer established.

This reduces your problem to ensuring that your daemon process is still
running (and there are a number of good solutions for that sort of
daemon supervision -- e.g. runit, daemontools, systemd, etc)

Finally, you could test whether the tunnel is up by sending traffic over
it and seeing if there is a response :)

hth,

	--dkg

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 1027 bytes
Desc: OpenPGP digital signature
URL: <http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20130427/1a83734c/attachment.bin>


More information about the openssh-unix-dev mailing list