AutoSSH on CentOS

I have been interested in MySQL replication over ssh and I wanted a way to make sure that the tunnel is always up. Everyone says to use AutoSSH. AutoSSH is not in EPEL, but is in rpmforge (Is that that same as DAG? Didn’t they merge?). I installed rpmforge:

rpm -Uhv

I don’t like to do the RepoDance, so I disabled rpmforge:

sed -i "s/enabled = 1/enabled = 0/" /etc/yum.repos.d/rpmforge.repo

Next I installed AutoSSH

yum install --enablerepo=rpmforge autossh</p>

And finally my Bash function to create an AutoSSH tunnel:

function StartAutoSSH {
	. /etc/rc.d/init.d/functions
	AUTOSSH_PIDFILE=/var/run/ # we are assuming only one autossh tunnel
	if [ ! -e $AUTOSSH_PIDFILE ]; then
	autossh -M29001 -f -N -L7777: [email protected]
	status -p $AUTOSSH_PIDFILE autossh

If you call this function, it will created the specified tunnel or if it is up and runnng, then it will spit back the PID.



  1. Safe SSH tunnel based Mysql updates (Well i think?) | - August 10, 2012

    […] Share this on:Facebook Twitter Delicious Digg Google Reddit Stumbleupon Email ← Asterisk integration with Huawei […]

  2. How can i install the right version of autossh on CentOS? - Boot Panic - January 23, 2022

    […] […]

  3. How can i install the right version of autossh on CentOS? - December 4, 2022

    […] […]