#!/bin/bash export AUTOSSH_GATETIME=0 function run_tunnel() { while true do autossh -M 0 \ -nNT -q \ -o ServerAliveInterval=30 \ -o ServerAliveCountMax=2 \ -o ExitOnForwardFailure=yes \ -R0.0.0.0:5022:127.0.0.1:22 \ -R127.0.0.1:8080:127.0.0.1:80 \ -R127.0.0.1:8443:127.0.0.1:8443 \ -p $2 $1 sleep 30 done } run_tunnel <> <>& run_tunnel <> <>& wait