I have a reverse ssh tunnel established between a client and a server computer. The client connects on the server on port 22, and creates a reverse ssh tunnel on port 4030.

After the client computer has created the tunnel, it will sent an email confirming the reverse ssh tunnel connection. I just need a command that will output something that proves that the reverse connection has been established, so I can include it in the email.

How can I do this?

  • netstat -antep |grep 4030 will show whether port 4030 is being listened Jan 13, 2016 at 16:53
  • running this on the client does not show any output
    – aristosv
    Jan 13, 2016 at 17:33

1 Answer 1


You may run an ss command (the modern version of netstat) on the remote system:

 ssh me@remote ss -ntp | grep 4030

but better still you should use autossh (it exists on all distros). It checks automatically whether a reverse tunnel is operating and, after some user-defined amount of time without receiving pings has elapsed, automatically restarts the tunnel.

I start it at boot time, and it works perfectly over weeks, if not months.

  • I haven't really had a good experience with autossh. I tried ss and it works perfectly though. But what if port 4030 is already occupied by another client? Won't my client report that the tunnel is established?
    – aristosv
    Jan 13, 2016 at 17:59
  • @aristosv That's why I included the -p flag: it will tell you which process is using the port, solving the above problem. Jan 13, 2016 at 19:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .