Part of the Cloud Backup solution was to add a client site appliance which would ‘stage’ the backup prior to them being moved off site to the replication servers. The software we use for this product requires a local copy running on the appliance – which needs to be administered by us remotely. As we are providing a ‘black box’ solution, we need to be able to monitor the box remotely.
In a previous post I refer to a method of doing this using SSH
with a -R
flag. That works really well, but if there is a power outage or a break in connectivity, the connection is broken. Enter: Autossh – a program that will try to reconnect to your proxy server or destination when the network connection drops.
Installation is pretty easy with FreeBSD
cd /usr/ports/security/autossh make install
And also with Ubuntu
sudo apt-get install autossh
In FreeBSD we added a file to ‘/usr/local/etc/rc.d/
‘ to start at boot time. There is some tweaking to get this to work as the autossh program does ‘unexpected’ things if it cant make a connection straight away. I recommend a scan through the man autossh
for clarity. Our file contains:
#! /bin/sh AUTOSSH_GATETIME=0 export AUTOSSH_GATETIME su ssh_client -c '/usr/local/bin/autossh -M0 -f -N -R 10098:localhost:22 me@proxy-server' su ssh_client -c '/usr/local/bin/autossh -M0 -f -N -R 10099:localhost:80 me@proxy-server'
This setup allows us to remote into the ssh port (22) and the web port (80) using the 10098 and 10099 ports respectively. We can now manage the cloud backup server behind most customer firewalls as the server is making an outbound connection. We can also use the ssh connection for Nagios monitoring.