bethaus-app/check_ssh_tunnel.sh
2025-03-16 19:54:47 +01:00

19 lines
506 B
Bash

# SSH Tunnel Check Script (batch script for cron)
# Add to cron: */5 * * * * /path/to/check_ssh_tunnel.sh
# --- Script to ensure SSH Tunnel is active ---
#!/bin/bash
SSH_USER="your_ssh_user"
SSH_SERVER="ssh-server-address"
LOCAL_PORT="2049"
REMOTE_NFS_SERVER="nfs-server-address"
# Check if tunnel is active
if ! nc -z localhost $LOCAL_PORT; then
echo "SSH Tunnel is down! Reconnecting..."
ssh -f -N -L ${LOCAL_PORT}:$SSH_SERVER:2049 ${SSH_USER}@${SSH_SERVER}
else
echo "SSH Tunnel is active."
fi