2018
08.13

So lately i have needed to setup some detailed entries into my ssh config file but i needed to ssh in and keep a term open for them to work.

Instead, i added these functions that when your ssh config is properly setup will auto create these tunnels for you:

start_tunnel:

function start_tunnel() { if [ -z $1 ] ; then echo "need hostname" ; else ssh -f -N -M -S /tmp/file-${1} ${1} ; fi }

stop_tunnel:

function stop_tunnel() { if [ -z $1 ] ; then echo "need hostname" ; else ssh -S /tmp/file-${1} -O exit ${1} ; fi }

the only thing that needs to be properly set up for this to work is the ssh config file since those functions read the Host section.