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.

--

--

--

A daily programming newsletter (https://abyteofcoding.com). Twitter: https://twitter.com/AByteOfCoding

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Introduction to Keycloak

Hacking Series Part 10

Beyond Jupyter Notebooks

Programming Language Trends

Creating Nested Routes and Resources for Ruby on Rails

Building a Discord Bot for ChatOps , Pentesting or Server Automation (Part 3)

How to Pick a Dedicated Development Team

Share with those who care

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
A Byte of Coding

A Byte of Coding

A daily programming newsletter (https://abyteofcoding.com). Twitter: https://twitter.com/AByteOfCoding

More from Medium

Docker Essentials & Security

Bash Scripting in Linux