#!/bin/bash

# Kill existing SSH processes using port 8444
ssh root@107.189.27.14 "lsof -ti:8444 | xargs -r kill -9"

# Wait a moment for cleanup
sleep 2

# Start autossh tunnel
autossh -M 0 -o "ServerAliveInterval=30" -o "ServerAliveCountMax=3" -o "ExitOnForwardFailure=yes" -v -N -R 8444:localhost:2001 root@107.189.27.14