autossh

Automatically restart SSH sessions and tunnels on connection loss

brewmacoslinux
Try with needOr install directly
Source

About

Automatically restart SSH sessions and tunnels

Commands

autossh

Examples

Maintain a persistent SSH connection with automatic restart$ autossh -M 20000 user@remote.example.com
Create a persistent SSH tunnel for local port forwarding$ autossh -M 20000 -N -L 8080:localhost:80 user@remote.example.com
Establish a reverse SSH tunnel with monitoring port$ autossh -M 20000 -N -R 2222:localhost:22 user@remote.example.com