how to check whether the ssh tunnel is up

Vincent Lin vintobe at gmail.com
Thu May 16 00:30:24 EST 2013


Hi Gert,

Yes, you're right, I tried and it turned out to be as you said. So what can
I do? Maybe I can check the 20001 port to see whether it's listening, but I
found when the socket is set up on the server side. It still needs to
notify ssh client side. And ssh client side should establish the local port
mapping to the destination  localhost:22.  Is that mean the only way to
find tunnel status is to send data from server side and look forward to
receiving the reply just like autossh?

Thanks
Vincent


On Fri, May 10, 2013 at 5:33 PM, Gert Doering <gert at greenie.muc.de> wrote:

> Hi,
>
> On Fri, May 10, 2013 at 10:44:59AM +0800, Vincent Lin wrote:
> > I have an idea. If we get the ssh process ID, then we can check the local
> > socket . Once the socket is established, the tunnel is OK. For example,
> >
> >  ssh [...] -R 20001:localhost:22
> >
> > We can check the socket that is used by specific ssh process. If the
> > Foreign Address is localhost:22 and state is ESTABLISH, the tunnel is up.
> > What do you think?
>
> This is not how it works.
>
> Unless someone actually connects to 20001 on the remote side, there is
> nothing on the local side that you could see in "netstat"
>
> gert
> --
> USENET is *not* the non-clickable part of WWW!
>                                                            //
> www.muc.de/~gert/
> Gert Doering - Munich, Germany
> gert at greenie.muc.de
> fax: +49-89-35655025
> gert at net.informatik.tu-muenchen.de
>


More information about the openssh-unix-dev mailing list