Opening SSH Tunnel in Script

# Setup the tunnel
$ ssh -M -S my-ctrl-socket -fnNT -L 50000:localhost:3306 user@sshtarget.com
# Check the connection
$ ssh -S my-ctrl-socket -O check user@sshtarget.com
# Exit when done
$ ssh -S my-ctrl-socket -O exit user@sshtargetcom
# Note that my-ctrl-socket will be an actual file that is created.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store