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?
Confirming that a reverse ssh tunnel has been established
ssh;ssh tunneling;tunneling
You may run an ss command (the modern version of netstat) on the remote system: ssh me@remote ss -ntp | grep 4030but 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. 