how to check whether the ssh tunnel is up

Vincent Lin vintobe at gmail.com
Fri May 10 12:44:59 EST 2013


Hi Daniel,

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?

Best Regard
Vincent



On Sat, Apr 27, 2013 at 11:48 PM, Daniel Kahn Gillmor <dkg at fifthhorseman.net
> wrote:

> On 04/27/2013 07:47 PM, Vincent Lin wrote:
>
> > Is it the only way to check the tunnel on the remote server side? How
> about
> > on the local client side?
>
> the tunnel you're specifying is:
>
>  ssh [...] -R 20001:localhost:22
>
> this means that sshd (on the remote machine) will listen on remote port
> 20001.  if a request comes in, then sshd will call across the
> established ssh connection to ask ssh (on the local machine) to create a
> connection to localhost:22.  I don't see a way to examine this situation
> from the client side, since the local side hasn't done anything yet.
> But maybe i'm missing something, and someone more knowledgable might be
> able to suggest an approach i'm missing. (e.g. see the autossh idea
> mentioned elsewhere in this thread)
>
> regards,
>
>         -dkg
>
>


More information about the openssh-unix-dev mailing list